Problem with Quaternions [ Resolved ]

Hi all,



Today i have a problem with Quaternions. I will explain my poblem, so i have a camera and one Spatial. I would like that my character look where the camera look at. I took the camera Quaternion and now i’ve want to take the rotation from the Z axis how shall we do this ? Do you have a solution ?

First Solution :



[java]ninja.setLocalRotation(quat.fromAngles(0,cam.getRotation().toAngleAxis(axis),0));[/java]



But i have a bug. In a certain position my character want to turn. :frowning:

I found the fonction for this.



If somebody is interested :



[java]

//In the Declaration

float[] f = new float[3];



//In the Update//

f = (cam.getRotation().toAngles(null));



//In the ActionListener//

ninja.setLocalRotation(quat.fromAngles(0, f[1], 0));[/java]

1 Like