Unclear as to how rotation works

We discussed this a bit in discord, but I’m unsure why the following does not work:

https://playcanvas.com/project/996692/overview/lookat

If you push the “d” key you will see it add 10 degrees to the y rotation, it will eventually get “stuck” and stop rotating.

If you push the “s” key then it adds 180 degrees to the current y rotation, you’ll notice that “sometimes” this flips it around, but if you use the d key a few times, then hit “s” it will sometimes not flip the entity around.

Euler angles are not stored on the entity. There are derived and applied to a transform

So a single rotation can be represented in multiple euler angle rotation.

If you rotate an axis more than 180 or less than -180, it will change the other axis euler angles to represent the rotation

If you need to rotate an entity on a single axis, rather than use getEulerAngles as a reference and adding to it, use entity.rotate or entity.rotateLocal instead https://developer.playcanvas.com/api/pc.Entity.html#rotate

Or have your own copy of euler angles that you are modifying in the script and applying to the entity.