Hello all.
I’ve been trying to figure this out but so far no luck.
In my script when i lose a life i got a text which goes from 3 to 0.
Now i want to add hearts instead of numbers
So far the numbers are working
So the script that work with the numbers is…
function OnTriggerEnter (collider:Collider) {
if(enable){
Destroy(collider.transform.gameObject); //destroy collided object
if(livesLeft > 0)
{
livesLeft --;
lives.text = “” + livesLeft;
}
Now i tried adding the hearts which i thought it would work but when i lose a life it goes from 3 hearts to 1 and i only got 2 lives now instead of 3. i tried doing different things but so far no luck.
Thanks all.
if(livesLeft >= 3)
{
livesLeft --;
lives.text = “” + livesLeft;
}
if(livesLeft >= 2)
{
livesLeft --;
lives.text = “” + livesLeft;
Hearts3.active = false;
Hearts2.active = true;
Hearts1.active = false;
Hearts0.active = false;
}
if(livesLeft >= 1)
{
livesLeft --;
lives.text = “” + livesLeft;
Hearts3.active = false;
Hearts2.active = false;
Hearts1.active = true;
Hearts0.active = false;
}