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