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 oliverdjc · Jul 11, 2012 at 01:25 PM · gamewavezombies

How would i make a point/wave system like this

Hello, I am trying to make a wave system so far i have this code. Which works well and makes it so it adds 5 enemy each wave and does it's job but in the picture bellow there there is art work getting shown every round, on round one it shows a 1 on round two a 2 and so on. How would you go about doing this?

Thanks for your time.

alt text

 #pragma strict
 
 var spawnPoints : Transform[];
 var enemyPrefabs : GameObject[];
 
 var yieldTimeMin = 2;
 var yieldTimeMax = 5;
 
 static var enemyCounter = 0;
 
 var spawnXOffsetMin = 0;
 var spawnXOffsetMax = 0;
 
 var spawnZOffsetMin = 0;
 var spawnZOffsetMax = 0;
 
 var defaultSpawnNumber = 5;
 
 var waveNumber = 1;
 
 var isSpawning = false;
 
 function SpawnEnemies(wave : int)
 {
         var spawnNum = (defaultSpawnNumber + 5 * (wave - 1));
         
         isSpawning = true;
         
         for(var i = 0; i < spawnNum;i++)
         {
                 yield WaitForSeconds(Random.Range(yieldTimeMin, yieldTimeMax));
                 
                 var object : GameObject = enemyPrefabs[Random.Range(0, enemyPrefabs.Length)];
                 var position : Transform = spawnPoints[Random.Range(0, spawnPoints.Length)];
                 
                 Instantiate(object, position.position + 
                         Vector3(Random.Range(spawnXOffsetMin, spawnXOffsetMax), 0, 
                                 Random.Range(spawnZOffsetMin, spawnZOffsetMax)), position.rotation);
                 
                 enemyCounter++;
         }
         
         isSpawning = false;
 }
 
 function UpdateWave()
 {
         waveNumber++;
         SpawnEnemies(waveNumber);
 }
 
 
 function Start () 
 {
         SpawnEnemies(waveNumber);
 }
 
 function Update () 
 {
         if(enemyCounter == 0 && !isSpawning)
         {
                 UpdateWave();
         }
 }
cod5nazizombieslvl29.jpg (24.6 kB)
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 whydoidoit · Jul 11, 2012 at 01:37 PM 0
Share

Please format your code by indenting it 4 spaces or 1 tab before pasting or by highlighting it and clicking on the code button after pasting. I've fixed it for you this time.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by CharlesD · Aug 15, 2012 at 07:09 AM

There are two option here, either simply use the GUI methods to draw the value of the waveNumber in a label on the screen or to use a bitmap font. A bitmap font will allow your text to be colored, smudged, stained, etc. I personally have not done anything with bitmap fonts, but this website seems to have some information on the process, and there are likely to be some existing topics on the matter, hopefully this helps you out.

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 eliteslayer · Jan 06, 2014 at 11:21 PM 0
Share

The Script spawn my enemies correctly but does not refresh start a new wave with more zombies. Any help with that Please.

avatar image
0

Answer by xwpedram_N · Jan 07, 2014 at 04:41 AM

use something like :

  var UserName = new Array();
  var UserRate = new Array();

  function OnGUI() {
   var Numbers : int = UserName .length;
 var rows : int = 0;
 for( var i = 0; i < Numbers; i=i)
 {
     if(rows % 2 == 1)
         GUI.DrawTexture(Rect(0 ,(rows * 130) + 4 ,Screen.width,128), ImgBG2, ScaleMode.StretchToFill,true);
         
     for( var j = 0 ; j < inrows ; j++)
     {
     
         try
         GUI.Label(Rect((Screen.width - 305) - ( j * ProductWidth) ,(rows * 130) + 14 ,165,10),UserName[i],style);
         GUI.Label(Rect((Screen.width - 305) - ( j * ProductWidth) ,(rows * 130) + 30 ,165,10),UserRate[i],style);
         i++;
         if(i == ProductName.length)
             break;
  }

and after new rate make

     UserRate.Clear();
     UserName.Clear();
         
     
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

8 People are following this question.

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

Related Questions

Multiple Cars not working 1 Answer

I need help with a companion!!! 2 Answers

Games and websites 1 Answer

play music on key press 1 Answer

Will not shoot, also my character will only move side ways. 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