get an objects rotation unity code example
Example 1: get objects z rotation in degrees unity
gameObject.transform.rotation.eulerAngles.z
Example 2: how to get rotation of object in unity c#
float angleX = myTransformGO.rotation.eulerAngles.x;
float angleY = myTransformGO.rotation.eulerAngles.y;
float angleZ = myTransformGO.rotation.eulerAngles.z;
Example 3: how to make the rotation of an object the same as another object in unity
Vector3 newRot = new Vector3 (otherObject.transform.eulerAngles.x, otherObject.transform.eulerAngles.y, transform.eulerAngles.z);
transform.rotation = Quaternion.Euler (newRot);