Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 FTheCloud · Aug 15, 2011 at 06:34 AM · enemydetectioninvoke

Determining That The Last Of A Bunch Of Spawned Enemies Has Been Destroyed

Say you spawn a bunch of enemies. How would you determine that all the spawned enemies had been destroyed and then invoke a function telling it what to do next?

I guess the best example I can think of would be COD Zombies where after you kill the last zombie of the round the next round starts. (if your involved with games you've never played Call of Duty Zombies then something is wrong with you :) here(1:12)

I know its a hard question so any help's 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
1
Best Answer

Answer by CHPedersen · Aug 15, 2011 at 06:41 AM

Not to worry, this is not particularly hard. :)

If you know how many enemies you've spawned, and you destroy them using the Destroy function, can't you just keep track of the number and count down?

I.e. if you spawn 20 zombies, then initialize an integer to 20. Then, every time the player kills a zombie and you have to call Destroy() on that zombie, decrement the integer by 1. Immediately afterwards, check its value. If the latest decrement caused its value to be 0, then that was the last zombie, and you will know it's time to load the next level, or whatever you do.

Alternatively, you can keep a list of all spawned enemies active at all time, and make sure you remove enemies from it when they die. Then, you have to check its Count-property for every kill, and if the Count becomes zero, then the list is empty, meaning the recently deceased enemy was the final one.

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 FTheCloud · Aug 15, 2011 at 07:03 AM 0
Share

Ahhhhh

Its so obvious now

Thanks

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

Enemy detection while pathfinding through the map 1 Answer

Player attacks once but the enemy takes double damages! 1 Answer

Making Enemy Retreat 1 Answer

Enemy Detection Area 1 Answer

How to correctly do an enemy ranged attack script? 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