Jump to content
  • Advertisement
Sign in to follow this  
Webbie27

Best 2D Collision method?

This topic is 895 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'm working on a 2D project. Currently I have a terrain and a falling man. Both these are 2D images drawn to the screen. I'm looking for a way to detect collision so that when my man touches the edge of the terrain, he starts walking along it. However I don't want to hard code in the terrains dimensions as I want it to be dynamic so with other levels if the terrain is in a different position he still behaves the same.

Share this post


Link to post
Share on other sites
Advertisement
You could give all game objects a bounding box, in 2d that would be just a rectangle. Then you compare rectangles against each other, to see if they collide. Simple and straight forward. The only tricky part would be for objects that don't fit well within the box. In that case you could use a circle.

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!