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
0
Question by RMsoftware1 · Jan 22, 2012 at 11:36 PM · objectlevelsone

One player, Many levels

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

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

4 Replies

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

Answer by IgnoranceIsBliss · Jan 22, 2012 at 11:51 PM

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.

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
3

Answer by syclamoth · Jan 22, 2012 at 11:47 PM

First: You just go to the 'file' menu, and use 'new scene'! If you want to go between different scenes during the game, use

 Application.LoadLevel(int);

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

 DontDestroyOnLoad(gameObject);

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.

Comment
Add comment · Show 3 · 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 IgnoranceIsBliss · Jan 22, 2012 at 11:53 PM 0
Share

You can also load a level by name if you want - use a string ins$$anonymous$$d of an int in your call to LoadLevel.

I find that this is a lot clearer to work with.

avatar image syclamoth · Jan 22, 2012 at 11:56 PM 0
Share

I hate doing that. String literals just rub me the wrong way.

avatar image IgnoranceIsBliss · Jan 23, 2012 at 12:02 AM 0
Share

I agree with the sentiment - but when it's an arbitrary order that may change at any time, it can be awkward. You're unlikely to change the name of a scene - and in fact, you can't do it from Unity at all (although you can do it from the file system).

Of course, if you plan on using different scenes for different devices, it makes a lot of sense to use integers rather than strings. I suppose it's use-dependent.

avatar image
0

Answer by RMsoftware1 · Jan 22, 2012 at 11:58 PM

Ok, Makes sense,just curious, is this Javascript or C#

Comment
Add comment · Show 1 · 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 syclamoth · Jan 22, 2012 at 11:59 PM 0
Share

Who are you talking to? Please post comments in the 'add new comment' section of the relevant post.

And to answer your question- Yes, it is Javascript or C#. All of the code that has been posted here will work equally well in both languages. In future, if you have more specific questions, it's nice if you specify what language you want, either in a tag or in your question text. That way we can help you more easily!

avatar image
0

Answer by RMsoftware1 · Jan 22, 2012 at 11:58 PM

Thanks i will try this later :)

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

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

A node in a childnode? 1 Answer

Stop Time for Specific Objects? 4 Answers

fade object out? 1 Answer

Is there a way to shake an Object fast? 1 Answer

What should I change in this instantiating a GameObject in a script using Unity? 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