Problem with raycasts

spy32
Posts: 19
Joined: Fri Aug 01, 2008 1:12 pm

Problem with raycasts

Post by spy32 »

Hi,
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
That is all what's important for you :), do you find the mistake. Please help :). Ah the problem is that the character isn't exactly set up 2 units over the ground. The chracter is set up about a bit less than 2 units and so the character is going up and down very fast. :p I hope you ve understood me and my bad english. Feel free to ask me questions about that :). Thank you in advance!

Note: The character simulation is working fine except of this little problem. The character is also able to climb terrains and stairs.

Chris