Jump to content
  • Advertisement
Sign in to follow this  
ravinDavin

Collision hiccups

This topic is 2501 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

Hi, Just wondering if its normal for sometimes pixel perfect collision detection to make the player go a small bit into a platform. And if it is not, What do you think causes it? Too many collision checks/too fast movement etc? Or just bad collision detection?

Share this post


Link to post
Share on other sites
Advertisement

Hi, Just wondering if its normal for sometimes pixel perfect collision detection to make the player go a small bit into a platform. And if it is not, What do you think causes it? Too many collision checks/too fast movement etc? Or just bad collision detection?


"Normal" is a relative term. Is it causing problems with a character's movement? It it a big enough overlap to be noticed by a player? Plenty of games are fun with less than pixel-perfect collision.

Sometimes a problem like that is due to rounding error, or subtle order-of-operations situations. Sometime's it's just lousy logic :-)

Post more specifics (like code and/or screenshots) if you need detailed feedback... otherwise it's kind of like you're calling your doctor on the phone and saying "Am I sick?".



Share this post


Link to post
Share on other sites
Hi thanks for reply. I am going to take out your point about rounding errors , it seems most likely for me. Would normally be calculating a 2D position on screen using a float type or an int? Or it depends on how I check stuff like bounding boxes etc?

Share this post


Link to post
Share on other sites
If your pixel perfect collision library is working as it should be, then it is a problem with the way you 'undo' the collisions. Check the future positions of your objects, not your current position after you move them but before you detect a collision. Ie.. Check for a collision at the end of the update before you move your object. 'Fix' the collision by reducing the velocity of the object until there would be no collision, and continue to check that object with its now reduced velocity against the rest of your objects.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!