I’ve learned the basic idea behind quaternions and why they are used, but I have a few questions related to their usage in Unity:
Why does Unity change the values I insert to the “Local rotation”? If I for example now put 0.55 into the camera, it changes it A LOT into 0.5238. What’s up with this? And why does it also change the other two of the “X”, “Y” and “Z” values?
Is it so that earlier Unity versions used Euler angles? At least some tutorials seem to show euler angles in the “local rotation”.
Is it possible to use euler angles for inserting the local rotation even if under the hood Unity would use quaternions? That would make tempering with the rotation a lot easier.
Is there an online quaternion to euler angle converter? I found the simple way to do that through code, but an online converter would be nice too. All I could find was the opposite: Online Conversion - Quaternion Conversion
Not that I’m aware of. Note that if you’re looking at screenshots of the inspector or something, the Normal inspector view shows Euler angles, but Unity is computing them from the underlying quaternion (and then converting any changes back again).
Sure; use Quaternion.Euler to compute a quaternion from euler angles.
So basically what I manually insert there makes it an invalid quaternion before the modification of the value? So basically the value space has only very rare discrete values that are valid? It’s weird how significantly it needs to change those, like in that 0.55 → 0.5238 example.
Hmm, the inspector view I have is showing Quaternions not Euler angles. So is there a setting to define that?
Yes, I am aware of that (which is what I was referring to with the “simple way to do that through code”), but I am meaning the very basic “local rotation” values you can set in the inspector and that are used by standard objects. Can you use euler angles for those somehow - without adding a separate code for that purpose?
It’s because you’re only changing one component at a time; the other three components do restrict what value(s) the component you’re changing can take on, because the relationship between them is such that the quaternion has to have unit magnitude (or whatever it is that ‘normalizedness’ represents for a quaternion).
Imagine doing a similar thing with a regular unit-length vector - say it’s (0, 0, 1) and you want to change it to (0, 1, 0). So first you enter 1 into the Y component - making it (0, 1, 1), which gets normalized to (0, 0.707, 0.707). Then you enter 0 into the Z component, making it (0, 0.707, 0), which gets normalized to (0, 1, 0). A similar thing’s happening with the quaternion when you edit it in the Inspector.
It shows the quaternions when in Debug mode, which is what I’m guessing you’re in. Look at the very top right corner of the inspector, next to the padlock icon, there’s a little dropdown icon that you can use to switch between Debug and Normal mode. (If this doesn’t work for you, I’ll need to see a screenshot of your inspector to figure out what’s going on).
Putting the inspector to Normal mode should show you a euler angle-based input for the local rotation.
Okay. Thanks a lot for the clarification! It doesn’t fully explain why it changes both the value you’re editing and the other value(s) too, as the 0.55 is not an impossible value any way - you can “scroll” the number to closer what you want it to be any way and putting it to something like 0.6 will make it closer to that 0.55. But probably the current behaviour is a good compromise, so that’s an adequate explanation to keep me from wondering it too much.
Excellent! Now this was the important thing in terms of practice! Thanks for pointing that out.This will make adjusting the angles a lot easier.