How to properly use entity.setLocalEulerAngles?

Hi everyone,

there are several posts about the unexpected behavior of entity.setLocalEulerAngles,
but to me it’s still unclear how to set the local rotation of an entity in regular degrees and returning the same values when using entity.getLocalEulerAngles.

Could anyone clarify this for me please?

Euler angles are not stored in the entity directly but instead applied to the transformation matrix.

GetEulerAngles actually calculates the X Y Z angles from the matrix. However, since a rotation can be represented in a number of different X Y Z Euler angles rotations, what was set earlier may not be the same as what you get out again.

If you need to work in Euler angles, it is recommended that you keep track of them yourself in a script.


Check how this example does it, to rotate the camera using the mouse:

1 Like

Thank you @yaustar and @Leonidas.
Now it makes sense to me :smiley:
I will check out the example project.

1 Like