How to add strafing to btKinematicCharacterController

dutchiedave
Posts: 1
Joined: Fri May 11, 2012 12:15 am

How to add strafing to btKinematicCharacterController

Post by dutchiedave »

Hi all,

I am using btKinematicCharacterController and it all works perfectly for walking and rotating. Can anyone give me any hints or references on how to add strafing. The code at the moment is:

Code: Select all

btTransform xForm;
        xForm = ghostObject->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.1) * 6.0 * -playerLocationControl.y;
        
        btScalar walkSpeed = walkVelocity * dt;
        
    if (playerLocationControl.x) {
        
    }
    if ( playerLocationControl.y) {
        walkDirection +=forwardDir;
    } 
    characterController->setWalkDirection(walkDirection*walkSpeed);
    
    if ( playerDirectionControl.x) {
        btMatrix3x3 orn = ghostObject->getWorldTransform().getBasis();
        orn *= btMatrix3x3(btQuaternion(btVector3(0,1,0), 0.02 * playerDirectionControl.x));
        ghostObject->getWorldTransform().setBasis(orn);
    }
    if ( playerDirectionControl.y) {
    }
Thanks,

Dave