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
1
Question by Chanindu · May 26, 2021 at 03:39 AM · levels

How do i make levels?

Dear Community, i am making a game of my own, (note:- i am a beginner) but i do not know how to make missions, i plan to make different games for it, but adding the same map over and over again is painful, so is there a thing i can use to make different levels? for i am very new, first started unity about 4 days ago

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

2 Replies

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

Answer by rage_co · May 26, 2021 at 05:00 AM

I am somewhat of a beginner myself, but i think the answer to your queries are Scenes and prefabs. You can drag any GameObject from your Scene view to the assets section and it will get converted into a prefab. you can easily drag and drop objects into your Scene view to create levels. Also, if you open and edit a prefab, the changes will be applied to all the objects created using the prefab.

You can use scenes to create different levels. After that you can C# scripts to load scenes. To load a scene, first add this at the top of your script:

 using UnityEngine.SceneManagement;

after that you can manage the order of scenes in File>Build Settings in the Unity editor and then easily load scenes with this command:

 SceneManager.LoadScene(<build index of the target scene goes here, scene 1 has an index of 0, scene 2 has an index of 1 and so on>);

If you want to load a scene which is a set number of index numbers before or after your current scene use this:

 SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + <difference in build index of scenes>);

you can use - insted of plus or even * or / if it has some purpose.

Hope this helps!

Comment
Add comment · Show 7 · 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 Chanindu · May 26, 2021 at 06:51 AM 1
Share

rage_co, thanks for your reply, i will try it, but do you mean when i copy the terrain data below the scene and put them to the assests folder, once i add them to another mission or scene it will be the same, do you mean that?

avatar image rage_co Chanindu · May 27, 2021 at 02:36 AM 0
Share

I did not fully understand your question, but It will create an exact replica of any object you create a prefab of.

avatar image Chanindu rage_co · May 28, 2021 at 11:48 AM 0
Share

Ok, thanks for your help

Show more comments
avatar image Chanindu Chanindu · May 30, 2021 at 04:29 AM 1
Share

i mean that when we copy the terrain file in assets and put it in another project the same map will be back???? thats what i meant

avatar image rage_co Chanindu · May 30, 2021 at 05:52 AM 0
Share

i think yes. prefab assets can be imported between different projects, however if you are using components or assets that aren't in the new project but are in the prefab (for example some movement script), be sure to import that too.

I am not completely sure but that should work

Show more comments
avatar image
0

Answer by Arano · Jun 02, 2021 at 07:56 AM

you can instantiate prefabs: https://docs.unity3d.com/ScriptReference/Object.Instantiate.html

as a script (in your menu scene maybe?) this is quite easy to setup, below some psuedo code:

 public GameObject levelBackgroundPrefab; //can be set in the editor inspector
 public GameObject level1ObjectsPrefab; //can be set in the editor inspector
 public GameObject level2ObjectsPrefab; //can be set in the editor inspector
 
 void StartLevel(int level)
 {
 GameObject levelInstance = instantiate(levelBackgroundPrefab);
 levelInstance.position = 10,10,10; //example
 levelinstance.getcomponent<weather> = snow; //example
 GameObject objects
 if (level == 1)
 objects = instantiate(level1ObjectsPrefab);
 if (level == 2)
 objects = instantiate(level2ObjectsPrefab);
 
 //do stuff
 object.getcomponent<player>.hp = hplastlevel; //example
 }



or you could just build the maps using prefabs, if scene A has prefab A and scene B also has prefab A, changing the prefab A in any of the 2 scenes (should) change it in both of the scenes.

https://docs.unity3d.com/ScriptReference/SceneManagement.LoadSceneMode.Additive.html could also be used to load multiple scenes op top of eachother (additive), but i think this is more advanced.

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

120 People are following this question.

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

Related Questions

How do I change scenes from triggers in UNity 1 Answer

Unity game level design patterns 0 Answers

How to add multiple levels? 3 Answers

players create level 0 Answers

Multiple Scenes for Multiple Levels, or One Scene with all Levels? 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