I’m trying to increase an integer by 1 whenever the player collides with a trigger, but instead it increases by 2, which means the function is called twice. I put comments next to where I made necessary changes to get what I want. But I’m asking this for several purposes in the future. Here’s the code:
var PortalActive : boolean = false;
static var PortalCount : float = 0; //Was originally int, but I changed it so it accepts 0.5
function Start () {
gameObject.renderer.material.color.a = 0.75f;
}
function OnTriggerExit (collision : Collider) {
if (collision.gameObject.FindWithTag ("Player")) {
if (!PortalActive) {
PortalActive = true;
gameObject.renderer.material.color = Color (0, 1, 0, 0.75);
gameObject.particleSystem.startColor = Color.green;
PortalCount += 0.5; //Was originally 1, but I changed it to 0.5 so I can get 1
}
}
}