I've got a problem with raycasts. I want to simulate an character (and I know the character demo!). I am raycasting a ray from the feet of the character stright down to the ground. With "ClosestRayResultCallback::m_closestHitFraction" I want to get the distance from raystart to the collision point. Here is my "pseudo-code", I can't give you the orignial code because the bullet engine is wrapped in our game engine and so on:
Code: Select all
// we have already the old position in "btVector3 oldpos" of the character, so now we have to calculate the new position:
btVector3 newpos(oldpos.x(), oldpos.y() + (2 - myraycallback.m_closestHitFraction), oldpos.z());
// set the new position and give it to the rigid body and clear angular velocity and rotations
Note: The character simulation is working fine except of this little problem. The character is also able to climb terrains and stairs.
Chris