I have a platformer type game being developed, I have it so that when you collect 50 items in any given level it will trigger a level complete sound. I also have a level select scene. What I need is that upon the collection of 50 objects the sound plays and the mesh render of an object in the level select scene is activated. Is this possible?
asked Mar 04 '11 at 04:32 PM
There are a few ways to do this, I would recommend using a GameObject with a script that holds your unlock data that does not get destroyed on Scene Loading and Unloading. Your level reports to this GameObject about the number of stars collected and other variables of import, and then your Main Menu retrieves the data from this GO when it is setting itself up when you come back in.
The way I did it in my game is that I have a "Base Scene" this is where all of my persistent objects live, and when I load in a level, I first destroy all the objects in the old level (via tags) and then LoadLevelAdditive (http://unity3d.com/support/documentation/ScriptReference/Application.LoadLevelAdditive.html) the new scene.
You can also use this: http://unity3d.com/support/documentation/ScriptReference/Object.DontDestroyOnLoad.html To make sure your data holder doesn't get destroyed when you load in a scene.
answered Mar 04 '11 at 04:47 PM