- Home /
 
               Question by 
               DiamondCharge · Sep 15, 2020 at 11:32 AM · 
                c#button2d gamebuttonsbuttonstates  
              
 
              How to Detect if a Button is Not Being Pressed
I am making a Shield for my 2D game and I enable it as soon as I press "Fire2", however it does not get disabled after I let go of the button. I have tried to use an else command to disable it, but I cannot get Unity to detect me leaving the button. Here is the code, please help!
 void Shield()
     {
         if(Input.GetButtonDown("Fire2"))
         {
             Shield1.SetActive(true);
             
         } 
         
 
      //This Does Not Work
         if(Input.GetButtonUp("Fire2"))
         {
             Shield1.SetActive(false);
         }
     }
               Comment
              
 
               
              Your answer
 
 
             Follow this Question
Related Questions
Moving Player Left/Right with Buttons 2 Answers
Looking for an invisible button (that actually works!) 1 Answer
how can I disapear a button after push? 1 Answer
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
               
 
			 
                