hi. I would like to ask on how will I be able to avoid multiplying my characters after loading a level. My character will travel to scene0 to scene1. After finishing scene1 it will return again to scene0. But after it returns, it doubles… what do you think is the problem
I’d check with a script to see before the scene has loaded whether there is already a character there, and if so, delete it, and if not, just carry on- so this way you’ll only have one.
You likely are instantiating your character in a script’s awake or start function. The object this script is attached to is being destroyed and reloaded when you load the second scene, triggering the awake & start again. You have a lot of options for how to fix this problem. Either don’t have the object that instantiates the character be loaded on every scene or check for an existing character before you instantiate, and don’t instantiate it the second time.
If I were you, I would use destroy. Also, make sure you don’t have DontDestroyOnLoad on the player during the scenes, as this would cause it to duplicate itself in the next scene.