Keep track of number of MP kills? (blueprints)

Enemy chected should have damage applied right calling function to hitted enemy? (i think UE4 got system for damage apply, check it out) On damage apply check if enemy heatl is <= 0, if it is kill and give point to player that last land the shot (or else you want to do it differently?). So you also need to make variable in enemy who shot last and always update it. Also, do you want to keep player health across all sessions and levels? If not you should use Pawn/Character instead of GameInstance to keep health

I feel like I should be able to figure this out considering I’m at this point in my project… but I think some guidance would be helpful here.

Basically, I have an MP game where there are human players and NPC enemies. I want to know of a simple way to log when a player kills a human player or a NPC separately. Starting with the human player.

I’m using line traces for shots. This works good. People die its all fun stuff. But the line trace originates from one player, and then applies x damage based on where the shot lands. The hit characters bp controls the take damage. I cant see how the shooting character would know whether or not they zero’d out the hit players health since they are in separate BP.

While writing this I just thought maybe I can store characters health into a unique variable in GameInstance_c called something like Player1Health.

And when apply damage is done in player1 char bp it updates this variable. If it hits Zero then theres now a shared variable I can use to populate a score… but understanding how to make sure the shooting character gets the credit is where im a bit fuzzy… thats if this is even the proper way to handle such things.

Thanks in advance for any ideas

Damage apply is already working. Players die when they’re health reaches zero.
I can keep track of how many times a player has died in the character blueprint. The issue is how do I keep track of how many players a character has killed. since they dont see the damage taken by the character they shot at.

I feel dumb. I figured this out in like two seconds when I actually started writing it out…

(after shot hits) Get Hit Actor → Cast to Mychar > Get Health > If = or less than 0 > Take “MPKills” and +1 and Set MPKills

blargh

EDIT: its actually not fully working. Once the “shooting” character is killed, the tally is reset on respawn… it needs to persist. hmmm…

EDIT 2: After checking if the shot player died I cast to a custom playerstate that you can make (and use in your project settings) of the shooter and add increment one to a variable called kills. At the same time update a local variable on the character bp with the same value in playerstate so that the UMG updates (set it from playerstate to character). Basically just save everything in playerstate variables and call them when you need to. Playerstate persists. Theres something finnicky with casting to playerstate sometimes but it works with some trying.

I know this Question is very old, but a nice way I used to keep that communication up is by adding a (reference to Self) to the damage message, then whomever receives the damages gives a response back to the person who sent the message (that opens a two way communication between shooter and target, then it makes it easier to store information like that :). (I agree on saving in the player state… although I use a gamestate makes it easier for me to keep track of all players …

I know this Question is very old, but a nice way I used to keep that communication up is by adding a (reference to Self) to the damage message, then whomever receives the damages gives a response back to the person who sent the message (that opens a two way communication between shooter and target, then it makes it easier to store information like that :). (I agree on saving in the player state… although I use a gamestate makes it easier for me to keep track of all players …