Unity input system only triggers once

Hi there, I recently started work on a platformer, and wanted to use the new Unity input system. Unfortunately, after setting it up, any input only triggers once, and holding down on buttons or keys does not register. It all worked with the old input system, but for some reason when I hold down a key, this is the result:
170911-xsqcotese2.gif
Ideally, as I hold down a key, the character would continue to move instead of just move a little.


As you can see, I have everything set up properly:


I am not using any interactions, and I am on Unity 2019.4.14 LTS.


Here is my code:

// Move
public void OnMove(InputAction.CallbackContext in_context) {
    // Apply horizontal movement
    float temp_movementDirection = in_context.ReadValue<float>();
    rigidBody2D.velocity = new Vector2(temp_movementDirection * speed, rigidBody2D.velocity.y);
}

Any help would be awesome!

The Player Input component is provided for convenience and it’s a mess. You should forget about it and deal with the new input system on your own, it’s a world easier:

using System.Collections;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using UnityEngine;

public class MyInputManager : MonoBehaviour
{
    public float movementDirection = 0f;

    // this is the class associated with the action map
    private PlayerControls controls = null;

    private void Awake()
    {
        controls = new PlayerControls();
    }

    private void Start()
    {
        // setup event handlers
        controls.Gameplay.Movement.started   += Movement_started;   // key down event
        controls.Gameplay.Movement.performed += Movement_performed; // key up event
        controls.Gameplay.Movement.canceled  += Movement_canceled;  // kinda same thing as performed
    }

    private void OnEnable()
    {
        controls.Enable();
    }

    private void OnDisable()
    {
        controls.Disable();
    }

    private void Movement_started(UnityEngine.InputSystem.InputAction.CallbackContext obj)
    {
         movementDirection = obj.ReadValue<float>();
        //Debug.Log("Movement action started.");
    }
    private void Movement_performed(UnityEngine.InputSystem.InputAction.CallbackContext obj)
    {
        //Debug.Log("Movement action performed.");
    }
    private void Movement_canceled(UnityEngine.InputSystem.InputAction.CallbackContext obj)
    {
        //Debug.Log("Movement action canceled.");
    }
}

Change Control Type to Axis

I can’t help you with the GUI based coding, but I can tell you that in C#, you need to use Input.GetKey(Keycode.Example) rather than Input.GetKeyDown(Keycode.Example)