Jump to content
  • Advertisement
Sign in to follow this  
dpadam450

Terrain collision

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

Im looking for a way to handle collision on a non-flat surface with a moving object (well say a ball). I know there is a collision if a.(x-p) = 0, but there is a vector of motion for a given plane. So once the ball hits, I want to find which way it's velocity starts to change. o . .. ... ball should move towards slope of plane(right down in this case). I need this to work for any arbitrary 3d plane though.

Share this post


Link to post
Share on other sites
Advertisement
The force of the impact is applied along the normal of the collision (vector difference between the collision points). For a sphere and a plane, it is just the normal of the plane.

Not quite sure what you mean by toward the slope of the plane, do you mean the sphere will slide down the plane or does it bounce off?

Share this post


Link to post
Share on other sites
I dont mean bouncing off of the terrain but say you jumped down a huge hill, you would hit the hill and then roll along the changing slope of the terrain? Like a skateoarder in ramp.

Share this post


Link to post
Share on other sites
Once you have the collision normal:
- to bounce the falling object: object.Velocity -= 2 * normal * Vector.DotProduct(normal, object.Velocity)
- to 'slide' the object along the plane: object.Velocity -= normal * Vector.DotProduct(normal, object.Velocity)

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!