Strange if I remove the if statement it works…but I want to control the force when the button is pressed and not always. Please advise thank you.
using UnityEngine;
public class AddForce : MonoBehaviour
{
public float thrust;
public Rigidbody rb;
void Start()
{
rb = GetComponent<Rigidbody>();
}
void Update()
{
if (Input.GetKey(KeyCode.Keypad5))
rb.AddRelativeForce(0, thrust, 0, ForceMode.Impulse);
}
}