Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 puzzlessouls · Nov 02, 2021 at 06:37 PM · spawnlevel-editor

How To Make Unity Level Object Spawner

Hi Can You Help ME To Create Unity Level Spawner. 20 Object To Spawn At Position 1s(0,0,20) 2nd(0,0,40)........

Get Object && Get SpawnCount.

Randomly spawn Object on 20 Position

if Level Restart Then load That same Level Again

Also Get Selected Object Set To Spawn On Different Level, Like 1 To 50,50 To 100;

Making Game For Android Iam New To Game Development 7 Days Iam Confused How To make this

Following Code Don't Matter Just Example. Can Suggest Your Way How You will do this.

// using System.Collections; using System.Collections.Generic; using UnityEngine;

  [System.Serializable]
 public class ObjectToSpawn
 {
     public GameObject Object;
     public int spawnCount;
 
 }
 
 public class LevelSpawner : MonoBehaviour
 {
 
     public Transform[] SpawnLocation; //Obstacles Spawn Location
     public ObjectToSpawn[] itemToSpawn; // Select Obstacles For spawn
     public int maxSpawnObject;  // Total Object
     private Vector3[] LastSpawnLocation;  //  if Level Restart Spawn Last Object And Its 
 }

// Another

 [System.Serializable]
 public class LevelSelection
 {
 
     public string Element; // Selected List Of Object And Count For Spawn
     public int LevelFrom;
     public int LevelTo;
 
 
 }
 
 public class ObjectSelect : MonoBehaviour
 {
 
     public LevelSpawner[] SetOfLevel;  //Get Selected Object To spawn
     public LevelSelection[] levelselection; //
 }
     ![See][1]![See][2]

   


[1]: /storage/temp/188202-how.png

[2]: /storage/temp/188203-how2.png

how2.png (27.9 kB)
how.png (193.8 kB)
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by hitesh007yt · Nov 03, 2021 at 01:18 PM

you could have made this extremely simple way. 1. make a level sector function(make sure to add "_selectedLevelIndex" int variable) 2. make a new empty scene for the game 3. make empty gameObject 4. into that empty gameObject add all the levels you wanted to add 5. make a script add that to the empty game object that has all the levels inside as a child 6. make that script responsible for enabling only one Level. that is based on "_selectedLevelIndex" and disable other remaining levels.

pros: 1. super simple to add this type of function 2. it will not use any type of instantiation function 3. performance cost will be lower and you will get like 2X more fps depending on the game. 4. you don't have to make a separate scene for every Level 5. overall game size will be lower

cons: 1. take sometime's to implement

Comment
Add comment · Show 2 · 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 puzzlessouls · Nov 03, 2021 at 03:17 PM 0
Share

ok iam working Can you share example or And tutorial Which To this.

avatar image hitesh007yt puzzlessouls · Nov 04, 2021 at 02:29 PM 0
Share

https://www.youtube.com/watch?v=bARhGg31MIs this is a car selector tutorial but you can apply the same concept with the levels

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

132 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 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

Best way to spawn new objects that arent already in the scene? 1 Answer

Ontriggerenter and InvokeRepeating problem 1 Answer

Can you name something that you spawned with a spawner script? 1 Answer

spawning rigidbodies next to each other 0 Answers

decrease draw call instantiated object 2 Answers


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