Constrain Velocity to Touch & Collision PROBLEMS!!

battleduckbattleduck Member Posts: 105
edited May 2012 in Working with GS (Mac)
Hi everyone, i have a small issue I'm trying to work out in the air hockey game I'm currently working on.
I have a paddle which is constrained to the players touch, and a puck with which it collides.
This all works fine & dandy, EXCEPT that if the player moves their finger (drags the paddle) very fast, then the paddle & puck move through each other without any collision, which obviously looks bad and glitchy.
I'm guessing this is to do with the speed of the two objects when they collide being too fast, and so they pass through each other before GS can recognise that they've overlapped.

I have the following rules governing the touch / drag of the paddle:
----------------------------------------------------------------------------
When Touch is pressed &
self.TouchDistance > magnitude( self.Position.X - game.Touches.Touch 1.X , self.Position.Y - game.Touches.Touch 1.Y )
Change self.Grabbed to True.

When Touch is released
Change self.grabbed to False
Change self.Motion.linearvelocity.X / Y / Angular velocity all to 0

When self.Grabbed = True
Constrain self.linearvelocityX to 60*( game.Touches.Touch 1.X - self.Position.X )
Constrain self.linearvelocityY to 60*( game.Touches.Touch 1.y - self.Position.Y )

--------------------------------------------------------------

I have set a max speed in the motion attributes for the puck & have ticked the "Apply Max Speed". And this helps in stopping the puck passing through the back of the goal. But because the paddle is constrained to touch, this method is of no use.

Any help or pointers in the right direction would be greatly appreciated.
Cheers guys.

Battleduck

Best Answer

  • ChirpinGamesChirpinGames Posts: 214
    Accepted Answer
    Hey Battleduck, I had a similar problem and got around it by adding a rule: onCollision divide actors motion by 2. This seems to work for me, but its not the perfect method. I'm hoping the next release will improve the fps and collision detection.

    Cheers

Answers

  • battleduckbattleduck Member Posts: 105
    Hey Chirpin,
    thanks for the reply, will give it ago and see what results it yields.
    cheers
  • battleduckbattleduck Member Posts: 105
    Have tried this and variations on it, I'm getting no noticeable difference.
    Any other suggestions.
    (Thanks again Chirpin for the fast reply)
Sign In or Register to comment.