Again, another error. Every time I do this, it doesn’t work. I even tried changing -UnityEngine.Vector3.forward to UnityEngine.Vector3.back, but it doesn’t work. Please help.
Rigidbody rb;
[SerializeField] float Thrust = 1f;
[SerializeField] float rotationThrust = 1f;
// Start is called before the first frame update
void Start()
{
rb = GetComponent<Rigidbody>();
}
// Update is called once per frame
void Update()
{
ProcessThrust();
ProcessRotation();
}
void ProcessThrust()
{
if(Input.GetKey(KeyCode.Space))
{
rb.AddRelativeForce(UnityEngine.Vector3.up * Thrust * Time.deltaTime);
}
}
void ProcessRotation()
{
if (Input.GetKey(KeyCode.A))
{
transform.Rotate(UnityEngine.Vector3.forward * rotationThrust * Time.deltaTime);
}
else if (Input.GetKey(KeyCode.D))
{
transform.Rotate(UnityEngine.Vector3.back * rotationThrust * Time.deltaTime);
}
}