I have this script that triggers a bomb explosion when clicked on with the left mouse button. When you click the right mouse button, it blows up all the bombs, but you only have a limited number of right mouse button clicks before that function is disabled. Unfortunately, the number goes down by however many bombs were blown up, instead of just once per use of the right mouse button. How could I fix that? My code seems sound to me. The GUI that is used to keep track of the “nukes” I have left is in the HUD script.
var prefab : Rigidbody;
var Stuff : Transform;
function OnMouseDown() {
HUD.Score += 1;
Destroy(gameObject);
var Spawn : Rigidbody;
Spawn = Instantiate(prefab, Stuff.position, Stuff.rotation);
}
function Update() {
if(renderer.isVisible)
{
if(HUD.Nukes >= 0)
{
if(Input.GetMouseButtonDown(1))
{
HUD.Nukes -= 1;
Destroy(gameObject);
var Spawn : Rigidbody;
Spawn = Instantiate(prefab, Stuff.position, Stuff.rotation);
}
}
}
}
Any help would be appreciated! Thanks!