Hello, I am Brand new to unity and I would like to know two things, Is it possible to have More than one scene in a game? If so, How would you do it.
Second: If it is possible, Can I use A Single player for the whole game, or do I have to put a player in every scene?
See, I use Game maker and I can make an object persistent for every level. Is that possible in unity?
Thanks Very much
First: You just go to the ‘file’ menu, and use ‘new scene’! If you want to go between different scenes during the game, use
where int is the index of the level. This index is set up in the build settings, which will automatically pop up if you go to create a build of the game.
Second: Yes, you can use a persistent object over scenes. What I usually do in these situations is put persistent objects in a ‘setup-void’ scene with only a few, minimal objects in it, and call
on each of the gameObjects that I want to keep. I then load the first level, but keep all the characters and game data from the ‘void’ level. The reason for this is so that I can move freely between the actual levels, without worrying about the game spawning a new GameEngine and Player if I happen to go back to the start.
Basically, you can easily make an object persistent between levels, using DontDestroyOnLoad. It’s not the only way to manage this kind of behaviour, but it’s the way that makes the most sense.
You can make multiple scenes in a single project easily. Try ‘New Scene’ in the file menu.
You can move between scenes using the Application.LoadLevel(“”) function. You will have to put these scenes into your final build using ‘Build Settings’ in your File menu.
You can use the DontDestroyOnLoad (http://unity3d.com/support/documentation/ScriptReference/Object.DontDestroyOnLoad.html) function on an object to prevent Unity from removing it when you move to other scenes.
Normally you would create an ‘Empty’ object in your first level, give it a behaviour that stores all of the player information in static members, and make sure it marks itself as DontDestroyOnLoad during the ‘awake’ or ‘start’ function. You can then use it as a persistent store of all of your player details and scoring.
Thanks i will try this later