Third person strafing action

hi, I'm making a game which use third person handler as input. I wonder, why the strafe right and strafe left action makes the character turning instead of strafing.  (see com.jme.input.thirdperson.ThirdPersonStrafeRightAction and com.jme.input.thirdperson.ThirdPersonStrafeLeftAction)

can someone explain what the codes below do?


public void performAction(InputActionEvent event) {       
        if (handler.getPermitter() != null
                && !handler.getPermitter().canBeMoved())
            return;
        handler.setStrafing(true);
        Vector3f loc = handler.getTarget().getLocalTranslation();
        if (!handler.isStrafeAlignTarget() && handler.isCameraAlignedMovement()) {
            rot.set(handler.getCamera().getLeft());
            rot.y = 0;
        } else {
            handler.getTarget().getLocalRotation().getRotationColumn(0, rot);
            rot.negateLocal();
        }
        rot.normalizeLocal();
        loc.subtractLocal(rot.addLocal((speed * event.getTime())));
}



i would like to make the strafing action which make the character direction always facing forward whenever it translate to left or right. Something like control in tomb raider game. Can anyone help me? the class will extend from keyInputAction (in similar format to what com.jme.input.thirdperson.ThirdPersonStrafeRightAction and com.jme.input.thirdperson.ThirdPersonStrafeLeftAction do).

Thanks.

Oh, i already found it, strafealigntarget must be set to true, but the strange thing is i have to swap between the thirdpersonstraferightaction and thirdpersonstrafeleftaction because the player movement somehow inverted when i set the strafealigntarget to true, …



and then setting the maintainazimuth to true in camerachaser and i get what i want :smiley: