- Home /
 
 
               Question by 
               TheEmeraldRuby · Jun 11, 2018 at 07:58 PM · 
                intframeincrease  
              
 
              How to increase two floats for every frame the space button is pushed down?
Hello, everyone. The title pretty much explains it all. How would I increase two floats by a value of my choice every frame the space button is pushed down? Thanks for your help!
               Comment
              
 
               
               
               Best Answer 
              
 
              Answer by fluxhackspro · Jun 11, 2018 at 08:05 PM
     float value = 0;
     float increaseValue = 5;
 
     void Update ()
     {
         if (Input.GetKey (KeyCode.Space)) {
             value += increaseValue * Time.deltaTime;//if you want it to increase with 5 each second
             value += increaseValue;//if you want it to increase with 5 every frame, which i would not recommend (about 60 times a second)
         }
     }
 
              Your answer