The rotation return to the old position

Hi !!!

I have a problem with rotation of my character…I have this problem many days before and I dont know to solve this problem…

I rotate my character to a positon pressing the “D” to rotate to right…for instance, but when make this, my character change your position…like show the image…Why this?


I try all updates and nothing…I dont know what

me = noob, but i think this is similiar to

i guess, like in that example, you overwrite your original rotation with the rotation set by keypresses, so you have to add the rotation by keypresses to your original rotataion.

Hi Pavel!

In my case is diferent…

In the class Player…that load my model…look the rotation that I make…player.setLocalRotation(new Matrix3f(1, 0, 0, 0, 0, 1, 0, -1, 0));

public void initPlayer(){

as far as i understand rot.fromAngleAxis(angulo, Vector3f.UNIT_Y);  sets the Quaternion to the values specified and does not take into account what is already stored in rot, so the old values are overwritten. to achieve this, you could try something like this, at least it works for me in a small test.

      Quaternion extra = new Quaternion();

i don't know if the  normalize() is needed though or should be called after the set(), i'm new...

An easier solution would be to do something like:

FileInputStream fis2 = new FileInputStream(caminho);

JmeBinaryReader jbr = new JmeBinaryReader();

player1 = (Node)jbr.loadBinaryFormat(fis2);

player2 = (Node)player1.getChild(0);

player = (TriMesh)player2.getChild(0);

player.setLocalRotation(new Matrix3f(1, 0, 0, 0, 0, 1, 0, -1, 0));


Node theNodeIWillControl = new Node("The Player's Node");


this.controlador = (KeyframeController)player.getController(0);

Such that the original rotation to orient the player is contained in the player trimesh, but the node you will be applying movement to with your D and A keys is its parent.


Thx a lot monjo and Pavel!!!