Setting LocalEulerAngle to 180 but when Getting it is a different number

So i’m trying to rotate a cube to face “Left” from whatever rotation they were previously facing.


this.entity.setLocalEulerAngles(0, 180, 0);
this.entity.getLocalEulerAngles().y;

Instead of receiving 180, I instead get 7.01670955022206e-15

All of the other angles work (90, -90, 0)

If anyone has an idea of why this is happening please let me know,

Thanks!

This is because euler angles are not stored internally for an entity. When you set Euler angles, internally, PlayCanvas sets a quaternion (the rotation of the entity relative to it’s parent). The code for that is here:

So when you call getLocalEulerAngles, the quaternion is converted back to quaternions. For your case, you’re probably getting 180, 0, 180. This is equivalent to 0, 180, 0.

Hope that explains what you’re observing.

1 Like