Jump to content
  • Advertisement
Sign in to follow this  
rnw159

collision detection for fast objects in tiles.

This topic is 3086 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ok, in a game I am working on the jump formula has the player moving at 15 pixels per frame when he gets near the ground. The problem is that you are moving so fast that the collision doesn't com in till you are inside the collision box instead of ontop of it. Because of the different variables you go through the box in different ways and sometimes you are 5-15 pixels deep before it catches you. Can anyone tell me some theory on how I could fix this?

Share this post


Link to post
Share on other sites
Advertisement
You can't do your physics calculations at discrete time intervals using the player's current position, because the player is moving. Performing calculations on only the current position doesn't account for the distance traveled since the last physics update. This is the problem you are currently having.

If you know the player's position, and the speed he is traveling, you know the exact path the player will travel for a certain time interval. Using this information, you can easily create a 'swept volume' of the player's path, and use this for your collision.

Since you are in 2D, the easiest to implement would be a swept circle.

When you perform the swept circle test, you will get the point at which the player intersects with the world geometry. You can then use this information to place the player so that he doesn't enter the geometry.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!