Advertisement

Collision Correction

Started by October 27, 2002 12:59 PM
3 comments, last by norman106 22 years, 3 months ago
Does anyone know how to make a player “Slide” along a wall so that he travels parallel to the wall once a collision had been detected? I’ve been looking all over the Internet for articles or tutorials for months now but I still can’t find anything. Can anyone explain how to create this effect? Any help would be appreciated!
There''s two common ways that I know of.

The first involves moving the player along the trajectory that causes the collision and then moving the player back along the surface normal that the player is running into. As long as the player ends up somewhere that doesn''t cause a collision you''re fine.

The second method involves casting two rays to the left and right of the original path. Whichever ray is longest after collision is the ray along which to move the player. This can be used when you don''t know the geometry of the surface you are hitting...it works as long as the surface is fairly even, and as long as you don''t mind changing the player''s direction vector without user input.
Advertisement
There''s two common ways that I know of.

The first involves moving the player along the trajectory that causes the collision and then moving the player back along the surface normal that the player is running into. As long as the player ends up somewhere that doesn''t cause a collision you''re fine.

The second method involves casting two rays to the left and right of the original path. Whichever ray is longest after collision is the ray along which to move the player. This can be used when you don''t know the geometry of the surface you are hitting...it works as long as the surface is fairly even, and as long as you don''t mind changing the player''s direction vector without user input.
I did this by finding the perpendicular to the wall normal. An easy way to do this is take (normal cross (move cross normal)).
Check the other recent thread on this subject:

http://www.gamedev.net/community/forums/topic.asp?topic_id=121285

Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.
Graham Rhodes Moderator, Math & Physics forum @ gamedev.net

This topic is closed to new replies.

Advertisement