Hello all,
I am trying to read my Jump into the PlayerController script from my GameInput script. The only thing that is not recognised is the return value from the new Unity input system. The animator is in the PlayerController script. That is why I only write in the PlayerController Update that I have received it.
Could you help me?
GameInput Script:
public class GameInput : MonoBehaviour
{
private PlayerInputActions playerInputActions;
private Rigidbody rb;
[SerializeField] private float jumpAmount = 7;
private void Awake()
{
playerInputActions = new PlayerInputActions();
rb = GameObject.Find("PlayerCanvas").GetComponent<Rigidbody>();
playerInputActions.Player.Enable();
playerInputActions.Player.Jump.performed += Jump_performed;
}
public float Jump_performed(UnityEngine.InputSystem.InputAction.CallbackContext obj)
{
rb.AddForce(Vector2.up * jumpAmount, ForceMode.Impulse);
float inputFloat = playerInputActions.Player.Jump.ReadValue<float>();
return inputFloat;
}
Thank you Greetings, Nico.