- Home /
Avoid altering prefab at runtime
I am making a game much like the old warcraft games.
In it, you have a soldier, which has an armor variable.
Later in the game, you are able to upgrade the armor for all soldiers - so it changes all soliders on my sides armor variable - and the armor variable of the prefab, i use to spawn new soldiers. I got this all working perfectly, except - when i stop running the game, the prefab saves the upgraded armor variable, instead of going back to how it was before runtime, like everything else does. This means the next time i run the game, they are already upgraded.
Obviusly i can do a workaround and set the variables to the start valutes in the function Start(), but im not a fan of workarounds.
Answer by Eric5h5 · Dec 10, 2013 at 02:05 AM
You need to instantiate the prefab and only makes changes to instances, not the prefab itself.