daemon3000 / InputManager

Custom InputManager for Unity
Other
587 stars 88 forks source link

InputModule Issue #9

Closed Adrenesis closed 9 years ago

Adrenesis commented 9 years ago

When trying to navigate fast in menus the allow bool doesnt trigger and you have to wait for m_nextaction.

Here is a way to solve it:

    private bool AllowMoveEventProcessing(float time)
    {
        bool allow |= InputManager.GetKeyDown(InputManager.GetAxisConfiguration(m_configuration,m_VerticalAxis).positive);
        allow |= InputManager.GetKeyDown(InputManager.GetAxisConfiguration(m_configuration, m_HorizontalAxis).negative);
        allow |= InputManager.GetKeyDown(InputManager.GetAxisConfiguration(m_configuration, m_VerticalAxis).negative);
        allow |= InputManager.GetKeyDown(InputManager.GetAxisConfiguration(m_configuration, m_HorizontalAxis).positive);
        allow |= (time > m_NextAction);
        return allow;
    }

I use m_configuration as a public string, so you can put the right configuration depending on controller.

If someone find a cleaner way to do it, feel free to post =).

daemon3000 commented 9 years ago

Fixed it. The bug was caused by the fact that the original version of the input module was developed for the built-in input manager where GetAxis and GetButton work on the same input axis. With this input manager GetAxis works only on DigitalAxis, AnalogAxis and RemoteAxis and GetButton works only on Button, AnalogButton and RemoteButton.

Original

private bool AllowMoveEventProcessing(float time)
{
    bool allow = Input.GetButtonDown(m_HorizontalAxis);
    allow |= Input.GetButtonDown(m_VerticalAxis);
    allow |= (time > m_NextAction);
    return allow;
}

Fixed

private bool AllowMoveEventProcessing(float time)
{
    string inputConfigName = InputManager.CurrentConfiguration.name;
    AxisConfiguration hAxisConfig = InputManager.GetAxisConfiguration(inputConfigName, m_HorizontalAxis);
    AxisConfiguration vAxisConfig = InputManager.GetAxisConfiguration(inputConfigName, m_VerticalAxis);

    bool allow = hAxisConfig.AnyKeyDown;
    allow |= vAxisConfig.AnyKeyDown;
    allow |= (time > m_NextAction);
    return allow;
}