Skip to main content
GameDev.net gamedev.net
🔒 Locked

Box Collision

Started by shiftytitan702 Dec 31, 2002 at 6:33 PM 1 replies 300+ views
Original Post
shiftytitan702
shiftytitan702
Hi, Mostly i think i am stupid, but i think that the collision detection tutorial on nehe.gamedev.net is a little over the complicated side of my abilities. I would like a reference or information on building collision detection(preferably box collsion), for a game i am building, and almost 1/2 way. so all i really need is the collision detection. my game will be a sidescroller, so box collision is all that is needed. would anyone please help me out. All help is appreciated Thank-you
xiros
xiros
The easiest, but fairly slow, thing to do is to check if the character will move into the box by using a single point for your character.

If its 2D, just check to see if the point your character will move to is inside all 4 sides. You can do this by checking if the test point is on the same side of each line as a point in the box.

Then if the test point is inside, just dont move into that area or move as close as you can to it and stop (intersection of two lines- edge of the box and line between current pos and new pos).

You can also find the normal of the side it will cross to make the character slide off correctly.

All the math is easy to find on the internet or just make it up as you go like I did.

If you want 3D collsion with a cube, just do the same thing but use 6 planes, its not much harder.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.