- Home /
Why does rotate angels does not match&
Hello everyone I have got a prefab with rotate (0, -90, 0). After create this prefab angles do not match. Can someone explain why?
p.s. weaponsInventary is a scriptable object, to witch attach bullet prefab
Create object function:
if (WeaponsInventary.instance.GetBulletsCount(currentWeapon.inventoryNumber) > 0)
{
Debug.Log("local rotation: " + currentWeapon.bullet.transform.localRotation);
Debug.Log("rotation: " + currentWeapon.bullet.transform.rotation);
Debug.Log("prefab name: " + currentWeapon.bullet.name);
...
}
Answer by Bunny83 · Dec 07, 2019 at 05:12 PM
Because rotation as well as localRotation are not euler angles but quaternions. There are countless questions about quaternions. In short quaternions have many advantages over euler angles which include: uniqueness, no gimbal lock, better animation support, easier to combine, less edge cases.
Note that you can get the euler angles by using transform.eulerAngles / transform.localEulerAngles. However keep in mind that those are computed backwards from the quaternion representation. Since several different euler angles combinations can represent the same rotation, this conversion might not be seemless. So the rotation 0,0,0 is the same as 180,180,180. You shouldn't rely on a specific euler angle combination.
IF you want to know more about quaternions I always recommend this numberphile video (and the extra footage) as well as the 3b1b video on quaterions
Your answer
