How can I make my grenade be throw-able only 2 times in every 1 seconds.
- Felipe
How can I make my grenade be throw-able only 2 times in every 1 seconds.
Every time you throw a grenade, set a dead time of 0.5 seconds - for instance:
var deadTime: float = 0; function Update(){ if (Time.time > deadTime){ // only check input when dead time has passed if (Input.GetButtonDown("Fire1")){ // if fire button pressed... deadTime = Time.time + 0.5; // update dead time... // and throw the grenade } } }
Check if the grenade was thrown 2 times in less than or equal to 1 second.
if grenade is instantiated, grenades ++