i created a boolean variable called “gameover” that is supossed to trigger game over related events, and i’m trying to change its value from false to true inside the OnTriggerEvent, if the variable life < 1
the problem is, i cant change it at all inside the OnTriggerEvent function (i tried removing every condition, printing its value in the console, making it start with “true” value and making sure it triggers game over events)
function OnTriggerEnter(colisao:Collider)
gameover = true;
any ideas? (oh, i also tryed making gameover a int variable, but the type doesnt seem to affect anything)
function OnTriggerEnter(other : Collider)
{
if(other meets some criteria)
{
gameOver = true;
}
}
Curly brackets are great- you can put them anywhere, even places without an if statement or anything. I use them to keep track of GUILayout vertical and horizontal blocks, so that I don’t accidentally push more than I pop.
oh, i had a pair of those in the actual code, but thanks anyway
i found the problem, game over was triggered by a player prefab, but since the palyer was destroyed, i couldnt really change a value inside it (i felt kinda dumb after i noticed). since life was a variable inside a gui texture script, a had no problem with that