I have a menu where a button called “Submit” can be triggered when a player presses the X button on a PS4 controller (Input.GetButtonDown). This brings up another menu that also has a button that is triggered with the X button. When I press down the X button on the first menu, I guess Unity reads this continuously and not discretely, and so the press of the X activates both buttons. How would I get it so that the user has to press the button twice and the menus work as intended?
So I came up with something, it works but it’s pretty hacky. I create an int called “xButtonPressed” that starts at a value of 2. After I press X, both buttons get triggered, but instead of jumping to the code that does what the 2nd button is supposed to do, I instead subtract one from “xButtonPressed”; I have an if-statement that only jumps to the code once xButtonPressed == 0.
You might also consider using Input.GetButtonUp() instead. That will fire when you let go of the button rather than when it is recognized as being pushed down.
I have had luck with that to avoid getting repeating hits.