Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by SpiritWebb · Nov 23, 2009 at 03:39 PM · scenelinking

Connecting scenes

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.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

3 Replies

· Add your reply
  • Sort: 
avatar image
8
Best Answer

Answer by burnumd · Nov 23, 2009 at 04:30 PM

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:

var levelToLoad;

function OnTriggerEnter (other : Collider) { //Check to see if a player entered the gate, rather than some space debris. if (other.gameObject.CompareTag("Player")) { Application.LoadLevel(levelToLoad); } }

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.

Comment
Add comment · Show 5 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image SpiritWebb · Nov 24, 2009 at 03:49 AM 0
Share

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?

avatar image burnumd · Nov 24, 2009 at 02:01 PM 0
Share

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.

avatar image SpiritWebb · Nov 24, 2009 at 08:03 PM 0
Share

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?

avatar image burnumd · Nov 25, 2009 at 02:01 PM 0
Share

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

avatar image fireDude67 · Nov 17, 2010 at 03:12 AM 0
Share

Please note that you can also use the Scene file name ins$$anonymous$$d of a scene number. Just be careful not to rename files without rena$$anonymous$$g the reference...

avatar image
0

Answer by Ehren · Nov 23, 2009 at 04:29 PM

You can use Application.LoadLevel to load your other scenes on demand.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by jpc133 · Apr 17, 2013 at 12:49 PM

You need to add to both scenes to the build settings.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

1 Person is following this question.

avatar image

Related Questions

Scene Connecting 5 Answers

Linking a prefab to another prefab in deep hierarchy using Inspector 1 Answer

GetPersistentManager problem? Can't save a scene anymore 1 Answer

Callback for when an object is deleted from the scene by the user in EditorMode. 3 Answers

Unity takes forever to load scene 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges