Search Unity

my variable doesn't reset it's value

Discussion in 'Scripting' started by brunoenvia, Aug 15, 2019.

  1. brunoenvia

    brunoenvia

    Joined:
    Aug 5, 2019
    Posts:
    94
    when i print in AddLife() the livesLeft value doesn't reset. when i click play in game
    i have 3 lifes and it adds to 4. when i stop playing, but if i start game again it goes from 4 to 5
    and so on, the variable livesLeft don't reset to 3. why is this happening?

    https://imgur.com/a/coUKRkv - you can see whats happening here

    https://pastebin.com/bMT4LLvr
     
    Last edited: Aug 15, 2019
  2. Antistone

    Antistone

    Joined:
    Feb 22, 2014
    Posts:
    2,836
    Please use code tags.

    Is it possible that you are modifying a prefab asset, rather than an object in your scene?