Check out example codes for "c# unity rotate first person controller script". It will help you in understanding the concepts better.

Code Example 1

public class myFPSBehavior : MonoBehaviour {
     public float rotationSpeed = 10.0F;
     
     void FixedUpdate()
     {
         if (Input.GetKey("escape"))
             Application.Quit();
 
         float rotation = Input.GetAxis("Rotate") * rotationSpeed;
   
         rotation *= Time.deltaTime;
 
         transform.Rotate(0, rotation, 0);
     }
 }

Learn ReactJs, React Native from akashmittal.com