Unable to move object using mouse cursor

I have attached a script to an object to move the later using mouse cursor but it’s not working. The public variable is appearing as expected in the inspector :

using UnityEngine;

public class RocketControl : MonoBehaviour
{
public float turningForce;
private Rigidbody rigidBody;

void Start()
{
    rigidBody = GetComponent<Rigidbody>();
    Cursor.lockState = CursorLockMode.Locked;
}

void Update()
{
    //Get our mouse controls

    float yaw = Input.GetAxis("Mouse X");
    float pitch = -Input.GetAxis("Mouse Y");

    //Rotate the rocket using controls
    rigidBody.AddRelativeTorque(
        pitch * turningForce * Time.deltaTime,
        yaw * turningForce * Time.deltaTime,
        0f);
}

}

@Saurav19j
Locking the cursor and keeping the mouse from getting yaw and pitch might be your problem. Because CursorLockMode.Lockedkeeps the mouse locked in the middle.

-Also, you didn’t show the value of “turningForce”, that will probably be the highest number driving the speed of your torque, so make sure it is not too low.