I made a script that gets when a certain variable = true, it subtracts 300 from another variable. The only problem is that it keeps subtracting and never stops. How can I make it only subtract once when it finds that it equals false? Thanks.
var LimbBroke : boolean = false;
var BodyArmature : GameObject;
var BodyMesh : GameObject;
var Blood : GameObject;
var SystemHealth : GameObject;
function Start ()
{
Blood.particleEmitter.enabled = false;
}
function Update ()
{
if(BodyArmature.GetComponent(LimbHealth).Health == 0)
{
LimbBroke = true;
BodyMesh.renderer.enabled = false;
Blood.particleEmitter.enabled = true;
SystemHealth.GetComponent(MainPlayerHealth).MaxHealth -= 300;
}
if(BodyArmature.GetComponent(LimbHealth).Health == 100)
{
LimbBroke = false;
BodyMesh.renderer.enabled = true;
}
}