- Home /
UI button selection with controller causing issues
I have a UI button that the player selects using a controller (pressing A on an xbox controller), the button is linked to a method and that method runs a coroutine that instantiates an object and is supposed to allow the player to place the object on-screen using the thumbstick then press A again to finalize the placement. The problem is when the player selects the UI button, that A button press is somehow registering as the same button press in the coroutine that finalizes the object placement so its not allowing any movement with the thumbstick since on the first frame it exits the loop. So my question is what can be done about this? How do I prevent the placement loop from exiting from the same button press that is done to select the UI button?
1)User highlights UI button and presses A on the controller 2)UI runs Method1 3)Method1 closes the UI and starts Coroutine1 4)Coroutine1 instantiates an object to be placed by the player using the thumbstick 5)Coroutine1 exits abruptly because it thinks button A was pressed.
if (Input.GetButtonDown("XboxA")) {Exit the object placement loop}
I also should mention if I disable this condition all the rest of the code works as intended and the player can place the object with the thumbstick, of course it just stays stuck in that loop since they cant finalize the placement.
Hopefully this is enough info, it seems like its a general question and not necessarily code specific but I can try to paste code if anyone needs me too, its just that the code is very long and would be cumbersome to parse through. Cheers.