I have made a chaseCam which chases a spatial. I would like to achieve that if I rotate the cam that the spatial is looking the same way (has the same y rotation). I’ve tried to set the rotation of the spatial in the update method but it doesn’t work. A camNode does the job but I can’t rotate the cam with the mouse (I was able to do this with an InputListener but the animation of my model stops if I rotate too quick). So to clarify what I want, I would like to rotate the spatial to the same direction as my cam so I always see the back of my character.
I tried model.setLocalRotatation(model.getLogalRotation().set(model.getLogalRotation().getX(), chaseCam.getVerticalRotation(), model.getLogalRotation().getY(), model.getLogalRotation().getZ())); but the spatial (model) didn’t rotate at all.
Try not to hand type code that could be easily cut and pasted because you introduce typographic errors that could obscure your issue.
At any rate, reading up on what Quaternions are could be beneficial as you seem to think the values mean something that they don’t. Quaternions are a black box magic structure and their values are not human-sensible. For example, “y” is not simply the y-rotation of an object.
My guess is that you are trying to keep any pitch/roll rotation and simply change the yaw? (ie: keep x-axis and z-axis rotation but change only y-axis rotation.)
As a general rule: A Java developer that does not have the javadocs one click away is not really a Java developer… so go ahead and “FRAMES” that browser window and leave it open forever.
If it works then it’s only randomly working and you will have problems later. Also, you are resetting the camera’s rotation which is a bit odd. At any rate, you are creating a corrupted Quaternion.
Quaternions are magic… you can’t just plug values in and hope they work. Plus, I pointed you to the exact methods you needed to do exactly what you wanted. Get the angles from the camera. Set the [1] angle back to the object with new Quaternion().fromAngles().