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 TheBigBang · May 10, 2014 at 05:14 AM · enemylevelcontinue

Enemy Spawn script not continuing level

I have a enemy spawn script that spawns enemies and increases its level every 20 enemies that appear. So on level 4 i have an special enemy that appears but after you destroy the enemy the level does not advance and no more enemies are created here is my script

 var isON: boolean = true;
 var level: int;
 
 function Update () {
 
     if (isON){
     transform.Translate(Vector3(direction * speed * Time.deltaTime,0,0));
     if (Time.time > lastSpawn + nextSpawn){
         Instantiate(enemy, transform.position, Quaternion.identity);
         level = manager.ShipCounter();
         manager.ShipCounter();
         lastSpawn = Time.time;
         nextSpawn = Random.Range(1.0,3.0 - (.2 * level));
         }
     }
     
     if (level == 4 && isON == true){
         isON = false;
         Instantiate(Enemyred, Vector3(0,8,2), Quaternion.identity);
         }
 }
 
 



I tried multiple approaches as removing the "isON = false;" but that just adds more than 1 enemy in the game and floods my gamescreen. Be great if anybody can help.

P.S. (IsON) is a trigger where i can either turn the spawner off or on during something situations i want to turn it back on after i destroy a specific enemy

Comment
Add comment · Show 4
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 koray1396 · May 10, 2014 at 08:18 AM 0
Share

you should be setting isON to true, when Enemyred is destroyed, then your script will run as usual as before.

avatar image TheBigBang · May 10, 2014 at 07:18 PM 0
Share

Thats the question i am asking how do i do that

avatar image Shmulzious · May 11, 2014 at 11:50 AM 0
Share

Wherever you are destroying EnemyRed try using getComponent to access the script mentioned above and changed the value of isON by a setter. That should do the trick if you mean to keep spawning after EnemyRed is dead.

avatar image TheBigBang · May 11, 2014 at 11:04 PM 0
Share

Alright i gotcha!

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Shmulzious · May 10, 2014 at 09:45 AM

The script you pasted does not have an area where isON goes back to true value after the redEnemy is spawned... To have it work you will need to set it to true either through redEnemy (on destruction or whenever you want it) or through a timer if you want the other enemy types to spawn even though redEnemy is still on the screen.

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
avatar image
0

Answer by LazyDog_Rich · May 10, 2014 at 11:40 AM

I think the problem can be in the manager.ShipCounter(); I mean probably it remains in "4" so when you turn "isON" true again, you gonna have "isOn && level=4" making the script turnig isON=false

Comment
Add comment · Show 2 · 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 LazyDog_Rich · May 10, 2014 at 10:51 AM 0
Share

$$anonymous$$aybe adding some condition like if enemyRed destroyed level = 5 isOn = true

avatar image TheBigBang · May 10, 2014 at 07:20 PM 0
Share

Thanks i'm trying actually figure out a script that was the question i was asking how to continue after i destroy it

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

23 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

Related Questions

Multiple Cars not working 1 Answer

enemy spawn and in game time counter 1 Answer

Trap Door Question 1 Answer

Enemy AI Help? 1 Answer

How to Stop Enemy "Shooting Through A Wall" 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