Jump to content
  • Advertisement
Sign in to follow this  
Ratman

Terrain/Projectile Collision

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

Trying to do collision response with a projectile and terrain. Say I have the terrain's surface normal where the collision took place (N) and I have a velocity vector of the projectile (V). I just need to reflect V across N (reflection = incidence). BUT Im thinking I can do with this without even looking at the angle and just get away with vector addition. Something like V = (V + (N*2) should work right? (assuming V is pointing in the direction the ball is moving, not pointing towards where the projectile came from). It looks close but not quite right in the game. I'm on no sleep right now and just wanted to "bounce" it off you guys :) Any suggestions? Thanks Ratman

Share this post


Link to post
Share on other sites
Advertisement
That looks right, thanks. Can anyone explain this a little more for me? I'm working it out on paper and it looks good but something just isnt clicking about why this is working. Thanks

Share this post


Link to post
Share on other sites
A picture would be best, but in lieu of that...

If N is unit-length, then V.Dot(N) is the length of the projection of V onto N.

Furthermore, V can be decomposed into two vectors, one of which is parallel to N and one of which is perpendicular.

The parallel component is:

V.Dot(N) * N

The perpendicular component is necessarily:

V - V.Dot(N) * N

Already we have a useful equation: V - V.Dot(N) * N gives us the component of a vector that is perpendicular to a plane with normal N.

Here we have subtracted from V the component of V that is parallel to N. Doing this once makes V 'flush' with the plane with normal N. Doing it twice reflects V through this plane.

Hm. Maybe not the best explanation - perhaps someone else will give it a try. But that's the general idea.

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!