hey guys! Ive got a problem… I want my player to destroy when he got <= 0 Liver left.
here is the code Im useing
var PlayerLives : int;
function update ()
{
if(PlayerLives <= 0)
{
Destroy(gameObject);
}
}
is something wrong or is it just a bug?
what do you mean by “is this a bug?” … you never described any problem(s) with this code …
ah lol^^ it wont destroy even if the lives is <= 0…
A function called “update” won’t do anything unless you call it specifically. A function called “Update” on other other hand will automatically run every frame…
–Eric
I’m at work, So when I get home I’ll post the exact script but try this.
var PlayerLives : int;
function update ()
{
if(PlayerLives <= 0)
{
Destroy(this gameObject);
}
}
Did that resolve your issue?
Jim Cullen
as long as it is update, not Update, it will never work