Question by
rgb1156 · Feb 16, 2017 at 08:57 AM ·
unity 5transformquaternioneuleranglestransform.rotation
What is the difference between setting transform.eulerAngles and transform.rotation?
How do these two differ?
transform.eulerAngles = new Vector3(0,0,0);
and
transform.rotation = Quaternion.Euler(0,0,0);
Comment
Answer by UnityCoach · Feb 16, 2017 at 09:21 AM
At this point, there isn't much difference. transform.eulerAngles is an accessor, it simply converts the rotation from/to quaternion.
The former will assign a Vector3 to a property that will convert it to a quaternion. The latter will create a quaternion from a Vector3 and will assign it to the rotation.
In the end, it's the same.
Though, if you want to use some variable, it's better to do it like this transform.rotation = Quaternion.Euler(0, 0, zRotation);
as it won't create a new Vector3 every time.