Add shift to a camera

Hello everyone

Is there a way to add an angle shift to a camera view ?

I’d like to make the main character head nod according to his breath but I can’t figure out how to do it

Thanks

Do you mean setting the direction of the camera? See the getDirection and setDirection methods!



https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:advanced:camera

I already tried to use them but it stops the camera view from listening to the mouse

Just using the setDirection method won’t stop the input handler from working. My guess is that you’re explicitly setting the direction on every update, which will force the camera to a certain position. What you’d want to do is modulate the current direction with something like:



[java]

Vector3f dir = cam.getDirection();

dir.x = dir.x*.05f;

dir.y = dir.y*.05f;

dir.z = dir.z*.05f;

[/java]

I understand !

Thanks, it works now !

The rotation method will work also if you combine the rotations correctly.



Even the approach above fails to renormalize the direction vector but the camera may take that into account… since internally it has to convert that back to a Quaternion again.