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 john-essy · Oct 22, 2011 at 05:29 PM · aispawnrestart

After player has died reset scripts

When the player has died and has went back to the main menu and clicked start game none of my scripts seem to be working mainly my spawning script Example:

 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 <= 0)
 
                 {
 
                     currentEnemies = 0;
 
                     spawnTime -= 0.1f;
 
                     AI.speed += 2.0;
 
                     ShipRotate.rotateSpeed -=0.1;
 
                     increaseRound = true;
 
                     maxEnemies += 1;
 
                 }
 
 
 
             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++;
 
             increaseRound = false;
 
         }
 
         
 
     if(spawnTime <= 0.9)
 
         {
 
             spawnTime = 0.9;
 
         }
 
     if(increaseRound == true)
 
         {
 
             round++;
 
             increaseRound = false;
 
         }
 
     if(maxEnemies >= 18)
 
         {
 
             maxEnemies = 18;
 
         }
 
 }
Comment
Add comment · Show 3
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 chemicalvamp · Oct 22, 2011 at 05:37 PM 0
Share

Have you tried deactivating the gameobjects and reactivating them?

avatar image john-essy · Oct 22, 2011 at 07:40 PM 0
Share

Do you mean when the player dies Deactivate them then when you press the start button activate them?

avatar image chemicalvamp · Oct 22, 2011 at 07:50 PM 0
Share

Yes, I did, but now that I think of it you might want to look into reloading the scene when you hit start. http://unity3d.com/support/documentation/ScriptReference/Application.LoadLevel.html

0 Replies

· Add your reply
  • Sort: 

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Need help with my enemy spawn script. 1 Answer

Ai finding target after spawning 2 Answers

Object Pool only activating one prefab 1 Answer

How to have a cloned/duplicated enemy react the same way the original does? 1 Answer

AI spawning areas. What are the ways to make them? 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