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

//This is how you rotate your player left and rigth with the wrrow keys:

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);
    }
}