Probably I can't explain in english what's happening so I just made THIS video showing the problem.
As you can see the character isn't moving properly(I think the correct word is 'flickering' but I don't know)
This 'thing' is accentuated by the fact that I'm recording but it happends also when I'm not
Ps: sorry if the video is a little bit dark
Edit: Here's the source code of the moving function
Code: Select all
void Move(float elapsedTime, bool f, bool b, bool l, bool r, bool j, Camera* cam){
if(m_pCharacterController){
btTransform xform;
xform = m_pCharacterGhostObject->getWorldTransform();
btVector3 forwardDir = xform.getBasis()[2];
btVector3 upDir = xform.getBasis()[1];
btVector3 strafeDir = xform.getBasis()[0];
forwardDir.normalize();
upDir.normalize();
strafeDir.normalize();
btVector3 walkDirection = btVector3(0.0, 0.0, 0.0);
btScalar walkVelocity = btScalar(1.1f) * 50.0f;
btScalar walkSpeed = walkVelocity * elapsedTime;
if (l)
walkDirection -= strafeDir;
if (r)
walkDirection += strafeDir;
if (f)
walkDirection += forwardDir;
if (b)
walkDirection -= forwardDir;
m_pCharacterController->setWalkDirection(walkDirection * walkSpeed);
btMatrix3x3 basis;
forwardDir.setX((float)sin(cam->GetYaw()));
forwardDir.setY(0.0f );
forwardDir.setZ((float)cos(cam->GetYaw()));
strafeDir.setX((float)cos(cam->GetYaw()));
strafeDir.setY(0.0f );
strafeDir.setZ((float)-sin(cam->GetYaw()));
upDir = xform.getBasis()[1];
forwardDir.normalize();
upDir.normalize();
strafeDir.normalize();
basis.setValue(strafeDir.x(), strafeDir.y(), strafeDir.z(),
upDir.x(), upDir.y(), upDir.z(),
forwardDir.x(), forwardDir.y(), forwardDir.z());
xform.setBasis(basis);
m_pCharacterController->getGhostObject()->setWorldTransform(xform);
cam->SetPosition(&Utility::ConvertVector(xform.getOrigin()));
}
}