Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

danielg

Collision Detection !!!

This topic is 5414 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! I have one silly question but I couldn''t find any answer or simple tutorial. My question is "How to make collision detection like in platform games with enemies, world, etc.". I''m trying to do that myself but I can''t. When I make rect collision with two objects it works, but if I increse the speed of object... it doesn''t work. Help me please!!!

Share this post


Link to post
Share on other sites
Advertisement
my friend who developed a mini mario-battle clone had the same problem (or was it that he did get the collision detection but depending on the char''s previous location his feet were up to 2 pixels into the floor).

What you''ll want to do is (before drawing anything) calculate everything''s next position. Then you check for collisions (if rect x is somewhere partly inside of rect y). That should work, unless the objects are fast enough to move ''through'' each other in a single frame (very doubtful, if they do, it''s not real movement, it''s teleportation). If the rect''s are ''inside'' each other, fix one (either one, the one that makes more sense... like if you have a rock and a mario, you probably don''t want to move the rock... unless that''s part of the game) so that they are only touching.

Share this post


Link to post
Share on other sites

  • 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!