Slide on collision behavior

Does anyone have an example or article on how to handle colliding, at an angle, with say a wall. I would like to slide along the wall instead of stopping

[quote]Does anyone have an example or article on how to handle colliding, at an angle, with say a wall. I would like to slide along the wall instead of stopping
[/quote]
You need 3 things:

  • collision point (tuple3f)
  • original end point (tuple3f)
  • colliding plane normal (vector3f)

The new end destination is projected by the normal of the colliding plane.

some psuedo code for the process using the vecmath library.


projectVec = new Vector3f();
newEndPoint = new Tuple3f();

projectVec.sub(origEndPoint, collidePoint);
newEndPoint.scaleAdd(-projectVec.dot(collidingPlaneNormal), collidingPlaneNormal, origEndPoint);

This should work… Of course optimize it for your need. Also remember that the new end point also needs to be checked for a collision between the 1st colliding point as well.