- Home /
Spawning a player when loading new level
A question about appropriate workflow. I'm creating a game with multiple levels. Should I manually add the player prefab and camera to each scene and make sure the settings are the same, or should I set both of these as a prefab which is spawned at the start of each level so that I can control their settings centrally via a script?
Thanks Baste, put this as an answer and I'll mark it answered.
Answer by Baste · May 15, 2015 at 07:35 AM
I'd spawn them. You don't want to suddenly have a character in one level have some value slightly off.
You'll need to have some central script that spawn all the things that are needed on each scene anyways - otherwise testing would be a nightmare. Relying on prefabs placed in the scene would also make things like having the player enter from different places much harder.
I'd spawn a prefab containing all the things you need in every scene - like the camera, the player, the UI, and so on.
Essentially, you want to be able to put down a plain, place out a single script that's a hook to starting everything, and press play.
When you're closer to release of an actual game, you can experiment with placing more stuff in each scene to see if that improves performance (I believe that instantiating stuff at Awake is a tiny bit slower than just loading it), but for development, making sure that the camera and the player and all of the other stuff is available for you to even test stuff will take a lot of time, and not be very fun.
Your answer
Follow this Question
Related Questions
Failed to load PlayerPrefs 1 Answer
Read only playerprefs? 1 Answer
How can I save highscores and display them for later? 1 Answer
NetWork: Random Player 2 Answers