- Home /
Structuring a damage and kill count method...
I had an issue thinking this up: what is the most effective way to add to a kill counter when an enemy's health reaches zero? I have about 20 enemies in a scene - how would I be able to do this?
Please, this is not a request for labor, so do not go on about down-voting. And also consider that my work is all in c#.
Thanks in advance!
Answer by dorpeleg · Mar 02, 2013 at 06:16 PM
Make a gameobject that will have your kill count script (or put the script on any other object that is not being destroyed).
In the kill count script, just have a public int for the kill count.
Then in your enemy script, add the following lines right before you destroy your enemy:
GameObject.Find("GameObjectName").GetComponent<KillCountScriptName>().KillCountVarName ++;
I think that should work.
Amazing work, dude! I had lots of problems with referencing scripts - but this is excellent. Thanks again for the hard work!
Your answer
Follow this Question
Related Questions
Damage Every Second Not Working 1 Answer
A node in a childnode? 1 Answer
Enemy Health Help 1 Answer
resources.load question 0 Answers