Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by Bradley_FDA · Feb 16, 2016 at 01:49 PM · c#arraysspawninglists

Increase List of Spawns Dynamically

Hello, I've been using some code (which I take no credit for using) which spawns enemies at set spawn points, at set intervals.

I have now included "blockages" to parts of the map. Meaning the player must remove them if they want to advance to a new part of the map.

Now I was hoping to make Spawn Points become "active" or "enabled" as the player removes these blockages. Pretty much like Call Of Duty: Zombies.

A huge thanks in advance if you can help me.

P.S: This is the spawning code that I have currently. using UnityEngine; using System.Collections;

 public class SpawnWaveGenerator : MonoBehaviour
 {
 
     [System.Serializable]
     public class enemy
     {
         public string name;
         public GameObject prefab;
         public float chance;
         public float delayTime;
     }
 
     public Transform[] points;
     public enemy[] enemies;
     public int SpawnTimer;
 
     enemy chosenEnemy;
 
     float random;
     float cumulative;
 
     void Start()
     {
         SpawnTimer = 0;
     }
 
     void Update()
     {
         SpawnTimer = SpawnTimer + 1;
         if (SpawnTimer >= 100)
         {
             SpawnRandom();
             SpawnTimer = 0;
         }
     }
 
     void SpawnRandom()
     {
         random = Random.value;
         cumulative = 0f;
 
         for (int i = 0; i < enemies.Length; i++)
         {
             cumulative += enemies[i].chance;
             if (random < cumulative && Time.time >= enemies[i].delayTime)
             {
                 chosenEnemy = enemies[i];
                 break;
             }
         }
 
         Instantiate(chosenEnemy.prefab, points[Random.Range(0, points.Length)].position, points[Random.Range(0, points.Length)].rotation);
     }
 }
Comment
Add comment · Show 1
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 meat5000 ♦ · Feb 16, 2016 at 01:51 PM 0
Share

Hrm, you lack a question here.

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by phil_me_up · Feb 16, 2016 at 02:02 PM

If you're asking how to enable / disable spawn points depending on progression within the game, then there are a number of possible ways.

One might be to have a spawn point manager which simple enables / disables the spawn objects (either the game object they are attached to or the component).

Another would be to simply have an 'active' variable in the spawn script which you change and test for in your updates.

Another would be to give each spawn script an 'active at' variable which is tested for. When the player hits level 4, any spawn point with an 'active at' value of 4 or greater would then allow spawns to occur.

These are just a few ways, the best way really does depend on your game but I'd probably have a spawn point manger which tracks all the spawn points and either enables / disables them, or just serves as a way of requesting / updating the current game progression.

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

93 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

Related Questions

Endless Runner with new Biome each time 0 Answers

All crops in list growing at once when they are supposed to grow individually 0 Answers

Copying a list of lists of int's in c# 1 Answer

Trying to program two buttons to appear when the player in my game dies 0 Answers

Only spawning power ups that the player wants in that game 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