- Home /
Displaying the total number of enemies & updating the number of enemies remaining as they're killed.
I am building a first person shooter game using Unity, UFPS, and Shooter AI. I am still a beginner in both Unity as well as C#. I want to display the total number of enemies initially and then the updated number of enemies remaining as they're killed. Please help me write a C# script for this purpose. Thanks in advance.
take one variable for totalEnemyToBe$$anonymous$$illed=50, take one counter for killedEnemy=0 and increase every time by one after death of each enemy. Take varible for remainingEnemy remainingEnemy=totalEnemyToBe$$anonymous$$illed-killedEnemy .
Answer by vietoilaviet89 · Apr 25, 2018 at 04:56 AM
Hi Shivamparke, you can try using a List enemies to hold all Instantiated enemy prefabs. Each time an enemy is killed, I mean he is also destroyed then display enemies.Count to have the number remain. this way will not only save the quantity but also the enemy detail information such as health, attack or anything like this. Hope it helps. .
Your answer
Follow this Question
Related Questions
How to delete prefabs without warning popping up? 0 Answers
Enemy wont damage player 0 Answers
Lerp in Coroutine (Crazy Behavior) 2 Answers
Run coroutine only when player stays inside collider? 0 Answers
Enemy wont damage player 2 Answers