How could i save a variable called by multiple objects using the same script?
What I want to do is be able to save a bool that checks whether some boxes in scene 1 are broken or not and when I return to that scene, those specific boxes stay broken. All of these boxes use the same script.
Answer by williamfalvo · Jun 25, 2020 at 08:41 AM
Try to use PlayerPref data, save for example a variable for Scene1 like as "brokenScene1 : true" and on Awake or Start check this data
Would this data save differently for all the different boxes using that one variable?
Ok I did it and ins$$anonymous$$d of just saving the variable, I save the variable and added the name of the object on the end so I could save each thing separately, it looks like this: Playerprefs.Setint("IsBroken" + this, IsBroken)
Your answer
Follow this Question
Related Questions
Why am i getting errors? 1 Answer
How can I replace objects in the initial position? 0 Answers
Unity won't build my scripts 0 Answers
Mobile attack button isn't doing damage to enemy 0 Answers
how to manage different objects with the same script. 0 Answers