I am guessing that you are trying to use a dynamic rigid body for your character controller, this can be difficult to control.
It would probably be easier to inherit the btKinematicCharacterController class and then modify it as needed since kinematic rigid bodies
are meant to be controlled.
If you are creating a custom character controller to be able to move in more than one direction you can look at the code
in this function and easily see how to change it as it is hard coded for 4 directions.
Notice that the velocity must be divided by the scale factor before passing to Bullet and vise-versa multiplied by the scale
factor when you get it back from bullet. This also applies to sizes of the objects and positions.
void agk::Move3DPhysicsCharacterController( UINT objID, int direction, float velocity )
//****
{
if ( !AGKToBullet::AssertValidPhysicsWorld() )
return;
if ( !AGKToBullet::AssertValidObject( objID, "Move3DPhysicsCharacterController: Object ID Is Not Valid" ) )
return;
if ( !AGKToBullet::AssertValidCharacterController( objID, "Move3DPhysicsCharacterController: Object does not have a controller. " ) )
return;
CharacterController* controller = characterControllerManager.GetItem( objID );
if ( controller ){
btScalar scaleFactor = GetCurrentDynamicsWorld()->m_scaleFactor;
velocity = velocity / scaleFactor;
btVector3 moveDirection;
if(direction == 0)
moveDirection = btVector3(0.0, 0.0, 0.0);
if(direction == 1)
moveDirection = btVector3(0.0, 0.0, 1.0);
if(direction == 2)
moveDirection = btVector3(0.0, 0.0, -1.0);
if(direction == 3)
moveDirection = btVector3(-1.0, 0.0, 0.0);
if(direction == 4)
moveDirection = btVector3(1.0, 0.0, 0.0);
//SITDS:Order Matters Call velocity before direction.
controller->SetWalkVelocity( btScalar( velocity ) );
controller->setWalkDirection( moveDirection );
}
}
The coffee is lovely dark and deep,and I have code to write before I sleep.