2 part question stemming from the same problem.
I am converting a game I started in Construct 2 to Unity. There is an overworld scene with a teeny sprite. Then each level goes to a side scrolling scene from the overworld. And before each level you can pick 1 of 4 characters to play as.
First off, I’m not sure the best way to store information tied to each character (health, ammo, etc). Unity seems to store the data on the actual object which would be great if I could just add “DontDestroyOnLoad” and let the same character with the same health and ammo continue from the last level. But I imagine I have to instantiate the selected character at the beginning of each level and let them get destroyed at the end.
The only solution I can think of is make an empty game object for each character. Store all the needed variables on that object. Add “DontDestroyOnLoad” to their scripts. Then before each level, transfer all the data from the empty game object to the instantiated Character Object. Then at the end of the scene, transfer the updated data back to the empty game object (spent ammo and lost health etc). Or is there a simpler way to keep all the data on each character between the scenes they aren’t used?
Also I am having a hard time getting general functions happening. Because the characters are all instantiated, it’s hard to target other objects. Like the health bar reacting to player taking damage. I end up tagging everything and then use “FindGameObjectWithTag”. But by the end of this game there will be hundreds of tags … is that typical? Seems a bit clunky and hard to maintain.
Any advice on how to approach this problem would be appreciated.