Jump to content
  • Advertisement
Sign in to follow this  

Basic collision detection and normals

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

[font=arial, verdana, tahoma, sans-serif][size=2]Hi guys,

I've been working on basic collision detection (ball and a plane) and I can get desired results using this formula[/font]

newVelocity = I - (normal * 2 * I.dot( normal )

But this is with a hard coded value for the surface normal. My question is, in a more dynamic setting (say a ball bouncing around a room with a cube floating in the centre) where there will be multiple normals? Do i have to do something like this..

if (collides with back of cube)
normal = (0.0, 0.0, -1.0)
if (collides with bottom of cube)
normal = (0.0, -1.0, 0.0)


and then use the formula to calculate the angle of reflection?

Thanks for any help


Share this post

Link to post
Share on other sites
You typically use a scene wide query. eg:

Vector3 collisionNormal;
Vector3 collisionPoint;
bool result = getCollisionFromAllObjectsInScene(oldVelocity, oldPosition, collisionNormal, collisionPoint);
if(!result) break;

// resolve collision

// update position and velocity of object

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!