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 SlyyGuyy · Apr 02, 2014 at 04:58 AM · javascriptspawningenemiesround

Round control and enemy control issues - Javascript

In the game I'm currently designing, I'm spawning enemies over time and after a certain amount of enemies are spawned/killed (or after a certain amount of rounds), I want the boss to spawn at the top of my screen. How can I enable this type of control? I can't seem to figure it out because I have two scripts set, one for the enemies and one for the boss. I'm unsure as to how to limit enemy spawning and ensure that my boss spawns. Here's the code for spawning enemies and then I'll also attach the code that is attached to my boss character -

Enemy Code:

 //Round Implementation
 var roundNumber : int; //If necessary
 var roundStarted : boolean; //If necessary
 var enemyLimit : int;

 function spawnEnemy() {
         
     yield WaitForSeconds(spawnTime);
     
     if(spawning) {
         return;
      }
      
        spawning = true;
  
        //Instantiate Enemies
        var seed = Random.Range(0, enemy.length);
        var x = Random.Range(-4f, 2f);
        Instantiate(enemy[seed], Vector3(x, 14f, 178f), transform.rotation) ;
        yield WaitForSeconds(spawnTime);
        spawning = false;
 }

Boss Code:

 var enemyControl : Enemy_Controls;
 var msDestruction : GameObject;
 var destructionSpawned : boolean;
 var destructionDefeated : boolean;
 var timesSpawned : int;
 var destructionLives = 10;
 
 function Start () {
     enemyControl = gameObject.GetComponent("Enemy_Controls");
 }
 
 function Update () {
 
 }
 
 function spawnMsDestruction() {
     //Access enemy controls in order to spawn the boss
         destructionSpawned = true;
     timesSpawned++;
     var go: GameObject;
     if(timesSpawned == 1) {
         //Ms.Destruction will "run away"
     }
     if(timesSpawned == 2) {
         //Ms.Destruction will "die"
     }
     
 }
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

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

20 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

Related Questions

I want that the enemies spawn in a random radius from the player, but not on other gameobjects like a housen or a car or something. 1 Answer

C# - spawn limit not working properly. 1 Answer

spawning script not working 0 Answers

Spawning won't work 1 Answer

Infinite runner spawning enemies, need some guidelines. 0 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