Unity SetButtonUp functionality

I have an issue with my game using the GetButton method in unity. When the button is held down the player continues to shoot as desired but if the button is held down while the game is paused and restarted for a new game, the button is still registered as pushed allowing the player to keep firing without pushing the button in the new game state. I'm trying to figure out if the SetButtonUp method will set the GetButton method back to false when a new game is started to fix the infinite shooting glitch. Any insight on how to fix this problem would be greatly appreciated. I've been looking online and I have found nothing on the SetButtonUp method or how to fix this issue. Thank you.

7/18/2018 8:25:38 PM

D Murry

1 Answer

New Answer


the code can be written like this(you can use getbuttondown) by that way you can use a boolean to make sure that if your pause menu is active (you can keep the pause menu in a gameobject and set it active and turn the boolean to true) [serializefield] GameObject pausemenu; bool ipo;//this is to check if pause menu is active void Update(){ //check if pause menu is active //if true set ipo to true if(!ipo){ if(Input.GetButton("whatever button"){ //what to do } }