Search Unity

Variables do not reset to default value after changing them at runtime?

Discussion in 'Visual Scripting' started by hillofgold, Dec 15, 2021.

  1. hillofgold

    hillofgold

    Joined:
    Dec 5, 2021
    Posts:
    2
    Hello all, i set up a simple space shooter where the player can upgrade things like rate of fire, bullet velocity, etc. but after i stop Play mode the variables do not revert to their original values, so next time i start Play it keeps all the "upgrades" of the previous session. What can i do to reset the values to default?
     
    Last edited: Dec 15, 2021
  2. hillofgold

    hillofgold

    Joined:
    Dec 5, 2021
    Posts:
    2
    To solve this, I tried using an instance of my projectile prefab, but since the projectile gets destroyed on hit / after a short delay when fired, the console says it "cannot access it because it has been destroyed". Am i supposed to keep all the used projectiles in memory? That would fill up my scene with inactive objects and cause performance issues. I can't find a solution to this mess, please help!
     
  3. Carcophan

    Carcophan

    Joined:
    May 10, 2021
    Posts:
    79
    I am having a similar situation. I do not know if this is the best solution, or the right solution for you, but I have just started reading about Pooling.

    Haven't implemented it yet, but it looks to be an avenue for me, so may be worth a few minutes to check out some YT videos.