Rotate animation:

FPS: I’ve got an animation, which is a human running. I’ve got a keyNavigator and I can move the player using a Vector3f walkdirection.This first person player is a PhysicsCjaracterNode. As the character move forward, I can see “my” legs and arms running with correct direction, but if I turn left/right pointing with the mouse, the PhysicsCharacterNode move in the right place, but the animation still runs forward as was doing before without turning on his Y-axis so the model doesn’t look where I am looking.

I suppose that I must rotate the model which is in the capsuleCollisionShape, so it will seems to turn in the right direction, but I found only the “.setLocalRotation()”; method that needs a Matrix or a Quaternion. So, is there a manner to transform my Vector3f in a Matrix rotation?

Or I’m following a wrong path?




You got it. PhysicsCharacterNodes are not meant to be rotated, just statically move around using walkDirection. You instead rotate the model to give the appearance to the player of changing directions.

Depending on how your inputs are controlling the character might determine how you would want to go about setting this rotation. However, knowing that you need to rotate the model now might point you in the right direction, as there are many ways to go about rotating a geometry. See if the standard Geometry.rotate(x,y,z) is enough. If not, then maybe you can form a quaternion from the direction vector and setLocalRotation using that?


Just look at TestWalkingChar. It does all you want to do and more.

Just look at TestWalkingChar. It does all you want to do and more.

I've read TestWalking source but I think my problem is little bit different. In TestWalk you can use a 3rd person character who can moves only in 8 direction: n,ne,e,se,s,so,o,no. But my player is a first person shooter, so I need to rotate his model around his Y axis while I'm looking differente places pointing with the mouse crosshair.
For example in quake, if you stay firm in a point, you can look around yourself just turning your neck.
If you turn "too much" others players will see you doing a little step on the same place to avoid your head behaving like Regan of "the Exorcist". I would to rotate automatically the model inside the capsule with the changing of mouse's direction.
For now I'm using:
CollisionResults results = new CollisionResults();
Ray ray = new Ray(cam.getLocation(), cam.getDirection());
shootables.collideWith(ray, results);
CollisionResult closest = results.getClosestCollision();
model.lookAt(closest.getContactPoint(), Vector3f.UNIT_Y);
It works each time I left-click. But I suppose is will be too much expansive to call that method for each simpleUpdate...
Other ways?