Constrain Velocity to Touch & Collision PROBLEMS!!
![battleduck](http://forums.gamesalad.com/applications/dashboard/design/images/defaulticon.png)
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
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
-
ChirpinGames Posts: 214
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
thanks for the reply, will give it ago and see what results it yields.
cheers
Any other suggestions.
(Thanks again Chirpin for the fast reply)