How do I make a "while button pressed down do x" action in the new input system?

What a great tool.

It’s great that we have manuals on how to override the great settings they made, but heavens forbid for them to put the important stuff in the manual, such as how to make a multiple frame action listener.

Great tool.
Anyone deciphered how to do it?

How is this:

…force the Input System to use my own template when the native backend discovers a specific Device?

In “…how do I?”

but “How do I make my object continuously move forward by holding down a button” isn’t ?

There are several ways to do it.

It’s the first time I am using the new Input system and I’ve been able to figure it on my own :wink:

Without using the Input Actions asset

using UnityEngine;
using UnityEngine.InputSystem;

public class MyMonoBehaviour : MonoBehaviour
{
    // Define the action in the inspector
    public InputAction inputAction;

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

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

    private void Update()
    {
        transform.Translate( Vector3.forward * inputAction.ReadValue<float>() * Time.deltaTime );
    }
}

Using the Input Actions asset (with C# generated class)

using UnityEngine;
using UnityEngine.InputSystem;

public class MyMonoBehaviour : MonoBehaviour
{
    public Controls controls; // Rename the class here according to the class name you chose in the Input Action Importer

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

    private void Update()
    {    
        // You will also need to rename `Player` and `Move` according to the value you gave in the Actions
        transform.Translate( Vector3.forward * controls.Player.Move.ReadValue<float>() * Time.deltaTime );
    }
}

151127-inputactionimporter.png

Using only a direct reading of the input from the device

using UnityEngine;
using UnityEngine.InputSystem;

public class ForwardTest : MonoBehaviour
{
    private void Update()
    {
        if( InputSystem.GetDevice<Keyboard>().fKey.isPressed )
            transform.Translate( Vector3.forward * Time.deltaTime );
    }
}

From what I’ve read here: 1

TLDR: @Rene-Damm: Yup, at the moment there’s no support for running logic continuously over time while a control is actuated so yup, it’d be up to OnFixedUpdate/OnUpdate and coroutines.

I recommend to anyone coming to this thread to do

Vector2 moveVector = new Vector2(
    (keyboard.aKey.isPressed ? -1 : 0) + (keyboard.dKey.isPressed ? 1 : 0),
    (keyboard.sKey.isPressed ? -1 : 0) + (keyboard.wKey.isPressed ? 1 : 0)
);

to get the most basic values that you require and use the same Update.Move() function to move your objects as you’d always used.

or leave the “new” input system alone for a pile of burning loveliness it is…

It is impossible to do what I asked in the initial question.