How to Rotate node with CharacterControl?

Hey, please, please I need your help
Here is my problem, when I had node without CharacterControl, I was rotating it doing

player.getLocalRotation().toRotationMatrix().mult(new Vector3f(0, 0, 50), v1);
player.move(v1);

but now I have added CharacterControl to it, and the only way I can move it is using setWalkDirection, but when I get WalkingDirection, it does not have method like toRotationmatrix(), So I have no idea how to rotate it. Is it possible to rotate node with CharacterControl, and how can I do it?

First, this:
player.getLocalRotation().toRotationMatrix().mult(new Vector3f(0, 0, 50), v1);

…was a long way to go to do:
player.getLocalRotation().mult(new Vector3f(0, 0, 50), v1);

Second, it isn’t rotating the player. It’s rotating a vector that you then used to move the player forward. So I’m unclear what you are actually trying to do.

It does seem like going over the “Math for Dummies” link might be helpful in the long run: https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:math_for_dummies

It doesn’t answer your question directly necessarily but it will give you the tools to form better questions if nothing else.

But if all you want to do is move in the direction the player is facing then it is already doing that… that’s what walk direction is.

if you want to rotate the node, you can maybe add a sub node to the node with the charactercontrol, then rotate this sub node. Plus, remember that there is a self-said “updated” version of the charactercontrol, even if i don’t like it very much : BetterCharacterControl.

If you only want to have an apparence which rotate on your node, you can use the solution of the sub node (minus some tweak to compensate the parent rotation). However, if you expect some “physics” reaction from this rotation, then … it’ll be a bit harder.

I see, I was not clear enough :slight_smile: I found what I was looking for:

if (right) {
Quaternion rotateL = new Quaternion().fromAngleAxis(FastMath.PI * tpf, Vector3f.UNIT_Y);
rotateL.multLocal(viewDirection);
}
//and at last
character.setViewDirection(viewDirection);

So the node with charactercontrol is rotating around it’s Y axis.

Note: fromAngles(0, FastMath.PI * tpf, 0) does the same thing.