Advertisement

Collision Response

Started by February 21, 2000 03:01 PM
0 comments, last by AndersG 24 years, 7 months ago
Hi, I''m making a FPS and I have just implemented som simple collision detection. The player has a bounding sphere and I''m checking the Position + Radius against different polys to see if I''m inside or not. If I''m inside (and wasn''t before) I use this formula to put me back outside: float Step=(player.Radius-Distance) / plane.length; player.position+=Step*plane.Normal; This works well for walls and right-angled floors, and I get the nice sliding effect against the walls. Now for the problem: If I put some angled floors in the scene, that tilts a little, then this function doesn''t put me on the outside any more, and I''ll walk right thru it. All the normals are correctly calculated and the normal length is calculated with: float l=sqrt(a+b+c); How do I solve this problem, I would really like to be able to walk across landscapes, and not just ordinary rooms!! There''s another question too: How can you make so that the player doesn''t slide down tilted floors automatically as soon as there''s some small angle, but just when the angle is above a specified range? I hope that someone can help me
You should divide the plane.normal with the length when you compute it, that way you don''t have to remember to divide with plane.length everywhere else. As far as I know you never need to have a normal with a length other than 1.

The length of a vector is computed with

length = sqrt(a*a + b*b + c*c);

This topic is closed to new replies.

Advertisement