|
Alright, what we are attempting to create is a Space Sim. The player starts in Sol System (Earth) and can travel through 15 different maps. We have a phase gate (at least one in each of the maps, maybe more) that will take you to different star systems. What we are curious, is how do we create the new scene? (which I think I found the answer by pressing control-N) And then link the new scene with the phase gates? We want the player to travel to ANY system using these gates. The goal is to eventually add mulitplayer capability, but thats far away! Any help would be greatly appreciated, and thanks in advance.
(comments are locked)
|
|
You've got the right idea so far. Create all your scenes in the Unity Editor (either with cmd (OSX) or ctrl (Win) + n or from File->New Scene). Create the scene order by opening the build menu (cmd/ctrl + shift + B or File->BuildSettings...) and dragging scenes from the Project view into the build menu. You can change the order by dragging them up and down in the build menu. You can now load new levels using the Application.LoadLevel() function. You can use either the scene name or its order in the build settings to determine which level to load. A simple example follows:
Where "levelToLoad" is either a scene name (enclosed in quotes) or a number. The variable can be set in the script or in the inspector when the script is added to some GameObject (in your case, a gate). One caveat: be sure you've read the collision detection matrix here to ensure you've added the correct components, or else OnTriggerEnter won't fire at all. If you have questions about that aspect of the editor or have trouble understanding the documentation, it would be best to search for or start a new question on that topic. Here might be a useful place to start. I tried to apply the above code, changed what I needed to change, but when I enter the phase gate, it tells me: "Level newscene couldn't be loaded because it is not added to the build settings. To add a level to the build settings use the menu File->Build Settings..." I have the scene added to the build settings, but still will not load. I also compiled it, and ran it, and it wouldn't do anything. Am I doing something wrong?
Nov 24 '09 at 03:49 AM
SpiritWebb
Using LoadLevel() with a string requires a case sensitive argument, so if the string doesn't exactly match, you'll run into problems. One thing you might test is to temporarily replacing the string argument with the desired scene's numerical order in the build settings. You'll probably also want to specify that you're using an int (change "var levelToLoad;" to "var levelToLoad : int"). If it doesn't load the level using that approach, let me know.
Nov 24 '09 at 02:01 PM
burnumd
I ended up getting it too work. I forgot to add the " " around the player argument. Now is there a way, say to allow a choice menu to appear on which star system they wanted to go and have it linked to say 3 different scenes?
Nov 24 '09 at 08:03 PM
SpiritWebb
I created a new thread for this question at http://answers.unity3d.com/questions/752/how-can-i-allow-a-player-to-select-from-multiple-scenes-to-load since it's a different question (primarily regarding the GUI system) and should get tagged properly
Nov 25 '09 at 02:01 PM
burnumd
Please note that you can also use the Scene file name instead of a scene number. Just be careful not to rename files without renaming the reference...
Nov 17 '10 at 03:12 AM
fireDude67
(comments are locked)
|
|
You need to add to both scenes to the build settings.
(comments are locked)
|
