Enemy Kill count tracker

I’m looking for a way to have my player character keep track of how many enemies they’ve killed over the course of the level. I don’t want that information displayed via a kill count through a HUD display, yet simply have a function that will check if a certain number of enemies have been killed and if so satisfy a condition. I’ve tried many different ways to get the blueprint to work but no luck so far.

I’ve tried creating an integer withing my NPC called death count, and have that number increase every-time a NPC is killed. The only problem is it only displays the kill of one individual kill and not the others prior, meaning there is no sum of the total number of enemies killed. I’m assuming I would need to use an array, to keep count of how many enemies died in total but I don’t know where to begin setting this up. My project has hit a dead end for a few weeks now trying to figure this out.

I’m still new to working in blueprint so anything helps.

1 Like

the total kills has to be saved by an actor that continues to exist throughout the level.
For example, in your npc blueprint just before you run destroy actor you can increment a kill count variable that exists in your player character bp.

to do that you will need to get a reference to the player, which can be done in various ways. there is an approach that works in single player games where you run “get all actors of class.”
for multiplayer, It would probably be best if you could get a reference to the player via the hit that killed the npc.

1 Like

I’d recommend this blueprints 101 tutorial to anyone just starting out:

1 Like

The answer of IndieGameCove is exactly correct:if the blueprint used to make your enemy disappear after being killed is Destroy Actor, just create a following system like this right after Destroy Actor:

As you can see,first you need to create a variable inside your character to count the number of enemy you have killed.After that go back to your enemy’s event graph and then cast to your character ( in this picture my character is called “Robo”)
, take out the variable you have created previously and use IncrementInt to add 1 to the variable every time 1 enemy is killed.

After following all of those instructions, all you need is create a binding in your UI to display the number of enemy have been killed, like this:

1 Like

Thanks All! This really help me out a lot. I was originally trying to use an array on my npc, and wasn’t thinking about the fact that since they were being killed off there was no way to keep track of that data via their own blueprint, and that I needed to keep track in my player character. I also wasn’t aware that the “IncrementInt” variable existed. Thanks a tone!

@IndieGameCove @anonymous_user_24691dcd yeaaaaaa thank you so much! These tips are STILL relevant years later.
@anonymous_user_d0d8af07 great that asked this and got such an awesome response for others (like myself) to find in the future! That little snippet of code to implement the count in the UI was the missing thing that I forgot how to do lol, again, thank you so much, take care :slight_smile: