Search Unity

Centralized Input System manager

Discussion in 'Input System' started by Nayan27, Feb 23, 2021.

  1. Nayan27

    Nayan27

    Joined:
    Oct 26, 2014
    Posts:
    1
    Hi,

    we are encountering an issue with the new InputSystem:
    We implemented a PlayerInput component which keeps track of the actions in this manner:

    Code (CSharp):
    1. gameplayActions["Jump"].started += ctx => {jumpPressed = true; jumpPressedThisFrame = true;};
    2. gameplayActions["Jump"].canceled += ctx => {jumpPressed = false; jumpReleasedThisFrame = true;};
    In the LateUpdate of this same component, we reset the variables jumpPressedThisFrame and jumpReleasedThisFrame to false.
    This works well only if we set the Update Mode to "Process Events in Fixed Update".
    Otherwise, other components could not consistently check playerInputs.jumpPressedThisFrame to replicate the behaviour of GetButtonDown() of the old input system.

    My question is: I get the feeling doing things this way is not the best. Am i not using the new InputSystem properly ? Would any one have some insight on how to centralize the input management and having other component reference this ?

    Thank you !