New input system triggers started when pressing AND releasing the trigger
Asked Answered
F

2

0

Hi! I’ve been trying to implement the new input system, but the started phase is triggered not only when I press the trigger but also when I release it.

It works fine with the mouse left click and with another generic controller I have which has a button trigger (it just returns a value of 0 or 1). However, with the PS4 controller that has a gradual trigger, the input system triggers started when releasing too unless I release it really fast. I’d say it isn’t controller’s fault, because it works fine in other games, its values when releasing are ok (I’ve checked it in a web), and I’ve tried two different PS4 controllers.

This is my code:

public void Fire(InputAction.CallbackContext context)
{
    if (context.started)
    {
        weapon.GetComponent<WeaponControl>().StartFiring();
    }
    else if(context.canceled)
    {
        weapon.GetComponent<WeaponControl>().StopFiring();
    }

    print("Fire triggered. Phase : " + context.phase);
}

When I press and release the mouse, these are the messages I get on the console:

FireTriggered. Phase : Started
FireTriggered. Phase : Performed
FireTriggered. Phase : Canceled

And these are the messages I get when pressing the PS4 controller trigger:

FireTriggered. Phase : Started
FireTriggered. Phase : Performed
FireTriggered. Phase : Canceled
FireTriggered. Phase : Started
FireTriggered. Phase : Canceled

These are my project settings (although I’ve changed them multiple times and none of the configurations worked):

Default Button Press Point: 0.75
Button Release Threshold : 0.5

I have no interactions or processors in my input map.

Fabianfabianism answered 13/3 at 22:31 Comment(1)

Hi, sadly I don't have a response :( But since it's an older question, I wanted to ask, if you maybe found a solution? We are having the same issue... X-box controller works fine, while PS4 fires both on press as well as on release and it's driving me nuts. Did you manage to solve it, or fight it successfully in some other way?

Doublecheck
L
0

I would try to set up an Interaction for the controller, as Trigger Behaviour choose Press Only that worked fine for me.

Latricelatricia answered 13/3 at 22:32 Comment(0)
T
0

I ran into a similar problem (2 years later!) Instead of doing work in Started I had to do the work in Performed and that fixed it. In the newer input system that’s changing from:

InputAction.Started += OnRightTriggerPressed

to:

InputAction.Performed += OnRightTriggerPressed
Troxler answered 13/3 at 22:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.