- Home /
 
 
               Question by 
               Jarretxx · Sep 27, 2013 at 10:44 AM · 
                function updatecooldownslowing-downvar type  
              
 
              Cooldown button system
heey im wanting to make a cooldown on my jump button but atm nothing is working ? hears my code
 var up = 0;
 var down = 0;
 var east = 10;
 var west = 10;
   
 var Forwards : GUITexture;
 var Backwards : GUITexture;
 var Jump : GUITexture; 
 var Left : GUITexture;
 var Right : GUITexture;
 var Jumpvalue = 7;
 
 var cooldown=2;
  var nextuse=10;
 
 function Start() {
 Input.multiTouchEnabled = true;
 nextuse = Time.time + cooldown;
 }
 function Update()
 {
 if(Input.touchCount > 0){
  
 for(var i : int = 0; i < Input.touchCount; i++){
 
 var touch : Touch = Input.GetTouch(i);
  
 
  if (touch.phase == TouchPhase.Stationary && Forwards.HitTest (touch.position)) {
   rigidbody.AddForce(Vector3.left * east);
  }
  if (touch.phase == TouchPhase.Stationary && Backwards.HitTest (touch.position)) {
   rigidbody.AddForce(Vector3.right * west);
  }
 for(var ii : int = 0; ii < Input.touchCount; ii++){
 
 var touch2 : Touch = Input.GetTouch(ii);
 
   if (Time.time > cooldown && (touch.phase == TouchPhase.Began && Jump.HitTest (touch.position))) {
   nextuse = Time.time + cooldown;
      rigidbody.velocity.y=(Jumpvalue);
     }
  if (touch.phase == TouchPhase.Stationary && Left.HitTest (touch.position)) { 
      rigidbody.AddForce(Vector3.forward * up);
  }
  if (touch.phase == TouchPhase.Stationary && Right.HitTest (touch.position)) {
      rigidbody.AddForce(Vector3.forward * down);
      }
 
 }
 }
 
 
 }
 } 
 Soo I need help with this ? 
 
               any ideas anyone ?
               Comment
              
 
               
              Answer by kat0r · Sep 27, 2013 at 03:01 PM
 if (Time.time > cooldown && (touch.phase == TouchPhase.Began && Jump.HitTest (touch.position)))
 
               should be
 if (Time.time > nextuse && (touch.phase == TouchPhase.Began && Jump.HitTest (touch.position)))
 
              Your answer
 
             Follow this Question
Related Questions
A node in a childnode? 1 Answer
Usage timer/weapon cooldown... 3 Answers
How to remove decimals from Vector3.Distance 3 Answers
How to initiate global cooldown? 1 Answer
Windows phone phantom touch event 0 Answers