using UnityEngine; using UnityEngine.InputSystem; using static UnityEngine.InputSystem.DefaultInputActions; public class RocketController : MonoBehaviour { public RocketDataScript rocketData; private InputAction jumpAction; // Start is called once before the first execution of Update after the MonoBehaviour is created void Start() { jumpAction = InputSystem.actions.FindAction("Jump"); } // Update is called once per frame void Update() { if (jumpAction.IsPressed()) Thrust(); } private void Thrust() { if (rocketData.Fuel > 0) { var rb = GetComponent(); rb.AddForce(rocketData.Force * Time.deltaTime * transform.up); rocketData.AddFuel(-1 * Time.deltaTime); } } }