unity how to get player rotation code example
Example 1: 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 2: rotate player unity
public class Test : MonoBehaviour
{
public float RotateSpeed = 30f;
void Update ()
{
if (Input.GetKey(KeyCode.LeftArrow))
transform.Rotate(-Vector3.up * RotateSpeed * Time.deltaTime);
else if (Input.GetKey(KeyCode.RightArrow))
transform.Rotate(Vector3.up * RotateSpeed * Time.deltaTime);
}
}