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 joeybbb · Dec 13, 2011 at 01:33 AM · hudzombieincreasefastround

Rounds increasing exteremely fast

Ok here is my script that controls the rounds and spawning of zombies:

 var AISpawn : Transform[];
 var allEnemies : GameObject[];
 static var currentEnemies : int = 0;
 var maxEnemies : int = 1;
 var minEnemies : int = 0;
 var spawn = false;  
 var spawnTime : float;    
 static var enemiesDead : int;   
 var enemies : int;   
 var round : int = 0;   
 var roundText : GUIText;   
 var increaseRound : boolean = false;
 
 function Start()
     {
         while (true)
         {
            if(currentEnemies <= 1)
           {
               currentEnemies = 0;
               spawnTime -= 0.1f;
               ZombieAI2.speed += 0.3;
               increaseRound = true;
               maxEnemies += 2;
           }
             if (currentEnemies <= minEnemies) 
                 spawn = true; // if minEnemies reached start spawning
             if (currentEnemies >= maxEnemies) 
                 spawn = false; // if maxEnemies reached stop spawning
             if (spawn){ // if spawning enabled create new enemy
                 // Randomize the different enemies to instantiate.
                 var obj : GameObject = allEnemies[Random.Range(0, allEnemies.length)];
                 // Randomize the spawnPoints to instantiate enemy at next. 
                 var pos: Transform = AISpawn[Random.Range(0, AISpawn.length)];  
                 Instantiate(obj, pos.position, pos.rotation); 
                 currentEnemies +=1;
             }
             yield WaitForSeconds(spawnTime); // free Unity for 2 seconds each loop anyway
         }
     }
 function Update()
 {
     roundText.text = round + "";
     enemies  =  currentEnemies;
     if(increaseRound == true)
        {
          round+=1;
          increaseRound = false;
        }
     if(spawnTime <= 0.9)
        {
          spawnTime = 0.9;
        }
     if(maxEnemies >= 50)
        {
          maxEnemies = 50;
        }
 }

when i run the game, the rounds just keep going up??? please help! It is greatly appreciated!!! Thanks!!!

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 loftail · Jan 29, 2012 at 01:22 PM

This was fairly simple to spot. The increase in rounds is when thier are no zombies, ie less than one as u said in your script. The error here is that at the beggining of the round, it is less than one always. You must add a timer as well that will chekc this after how ever much time. That will allow your first zombie to spawn, then when the last zombie has died, it will always be checking and the next round will start. Then that function will be called again and it will start again, so i do not think u will come across any errors.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Enemy Spawning 1 Answer

Zombie Round Script Help 1 Answer

Rounds reset 0 Answers

Spawner + AI control 2 Answers

Help with zombies Spawning 5 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