Timeline for Check if all gameobjects are destroyed
Current License: CC BY-SA 3.0
6 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Nov 9, 2016 at 23:00 | comment | added | PompeyPaul | I think you should carefully study this. Especially point 9 howtomakeanrpg.com/a/not-your-problem.html | |
Nov 3, 2016 at 13:35 | comment | added | DMGregory♦ | I would consider that a false choice. We can solve this problem in a way that's both simple/fast to author and efficient to run - I've added an answer to demonstrate. It's the same concept described above and in the other answers, just with a drop-in example to show how little code and maintenance is required. | |
Nov 3, 2016 at 9:16 | comment | added | PompeyPaul | It can be slow. However I would suggest going with this method and then when you get to a game you are happy with that is the time to profile & optimise. Other solutions are incredibly over engineered and if it turns out the game mode doesn't work as thought it's a few lines to delete. Removing the larger solutions given is going to be far harder. Plus they'll take longer to implement when getting to the game loop is the key here. | |
Nov 1, 2016 at 21:49 | comment | added | DMGregory♦ |
Note that searching for the objects frequently (eg. every frame) can be quite expensive and slow. It may be better to have the EnemyScript increment a shared counter on Start() (to say "I am here"), and decrement that counter in OnDestroy() (to say "I was shot"). Then you always know the number of active EnemyScript s without searching for them every time (handy if you want to display this number in UI, etc). You can have the decrement method check for zero and fire off the "everything destroyed" event in response.
|
|
Nov 1, 2016 at 21:44 | vote | accept | Hudhud | ||
Nov 1, 2016 at 21:30 | history | answered | PompeyPaul | CC BY-SA 3.0 |