I have these game objects in the main menu (play, settings, etc.) that can be selected with either the mouse or a controller by hovering over them and clicking the mouse or pressing x / a depending on the controller type. Previously, this was written:
if (Input.GetKeyDown(KeyCode.Mouse0) || ps4Controller.Land.X.ReadValue() == 1)
and that worked fine, but my issue is that the buttons would get pressed if I was holding down the X button on the controller before I even hovered over the game objects. So while the X button was already being pressed and the “float” value was 1, if I hovered over a game object, the game object would be instantly selected. I wanted to change it so that if the X button was RELEASED on the game object, then it would be selected. I figured using “canceled” would work, but it doesn’t seem to, so what can i do here? How can I make “canceled” work in the if statement? P.S. I’m new to Unity.

What does it say if you hover over “canceled”? Could it be that you spelled it wrong and it should be “cancelled” instead? I am not exactly sure what class you use here for the controllers but you could do your own checking if it is released or not. Here is an example of the top of my head:
private float myCurrentValue;
private float myLastValue;
private bool myClickedThisFrame;
void Update()
{
myCurrentValue = ps4Controller.Land.X.ReadValue();
if(myCurrentValue == 1 && myLastValue == 0)
myClickedThisFrame = true;
else
myClickedThisFrame = false;
myLastValue = myCurrentValue;
}
You check every frame what the currentValue is and you also save the value for the last frame, by keeping these variables you could know if the button was just released, if it is currently being held or if it was just clicked. I show you how to check if the button was clicked this frame but I am sure that you can figure out the logic for the other scenarios aswell. The class that you work with probably already has this feature but this could be how it is working underneath. It is not the best solution because you call on ps4Controller.Land.X.ReadValue every frame but I don’t think it will be a big hit on your performance.