- Home /
I want to know how to script a kill counter
I have no clue where to start on how to make a kill counter everytime i kill an enemy, im new to unity please be kind XD
We'll let you live, but it's the last time. This isn't a place for kindness. This, is, UNITYANSWERS ! :p
$$anonymous$$ore seriously, follow $$anonymous$$ike's tutorials. They will answer your question and so much more.
Answer by whydoidoit · Jun 01, 2012 at 04:56 PM
It OK to be new :) Answers isn't really going to help you too much though unless you have a specific problem not a whole general area you need to understand.
As I recommended on your other post - go work through some tutorials. They will really help you to understand what is possible.
Answer by pborg · Jun 01, 2012 at 07:00 PM
The basic element of the script would be to add a death() function to the enemy files that activates when the health<=0. function death() { player.killcount++; destroy(); }
make the killcount variable a static integer so that the enemies can access the value. To display the counter add the variable to the OnGUI() function. I apologize if my notation is improper.
In that case, the variable would be accessed through the class, not the instance. Unless player is actually the class.
Your answer
Follow this Question
Related Questions
Roguelike Elements... 1 Answer
Enemy kill counter and time limit. 1 Answer
How to realize accurate time counter (millisecond precision) 3 Answers
Gun Script not working help please 2 Answers
Gun script help 1 Answer