Score goes up when NPC dies

Hello, im experimenting with unreal engine. and after watching countless tutorials, i seem to be stuck. I can not for the life of me figure out how to make a point system that goes up when an NPC dies. It probably isnt the hardest thing to do, but ive tried following 3 different tutorials and nothing worked. any help would be appreciated, let me know what you would need screenshots of as well

Hey there, it’s a singleplayer game? Can you show me a screenshot of the Apply Point Damage function call and the Event Point Damage?

That should be the Apply damage thing, and i think thats the only thing with apply damage in it. i dont have anything with event point damage i dont believe.

Yes, it is a single player game.

Thank you for any and all help

Below you will find a basic blueprint on how to accomplish what your looking for. essentially when the ncp’s health drops to zero you want to cast to the player character or wherever your score value is stored. you then need to get the score value add whatever amount you want to it then reset it. at this point you can play your death animation or destroy the actor.

1 Like

Thanks a lot for that, how would i go about adding it to the widget?

Check the answer below from ThompsonN13, that’s pretty much what you have to do.

that is what my widget looks like currently

that should work just fine.

i got it to work except it isnt adding up the points, just replacing them. {ex 100, 100, 100, 100… instead of 100, 200, 300, 400.)

do you have the npc adding points when it dies? if you look at the picture i posted above after i cast to the player character i get the score then i add a amount then i set the score. by doing this the score gets incremented.

this is how i have it set up, the first destroy before it is for projectile then the points then destroying the guy

are you using the third person character as both the player and the enemy? try using some print strings to locate where the script is failing(enemy heath reaching zero for instance). i would also have the projectiles destruction on the projectile’s blueprint. its good practice in my opinion to have the logic that affects a actor located within the actor itself.

I am using the third person character as the player and then a character blueprint for the enemy, putting the projectile’s destruction with the projectile would make a lot of sense in practice, but im very inexperienced so my whole ‘game’ is jerry rigged tbh

i think i might be an idiot, it is probably correct but i had the points on the third person character and not the enemy :s the little oversights cause the biggest problems. Thanks for everything i really appreciate it.

the script i gave earlier was meant to go in the enemies event graph. so how you have it now if the enemy isnt a thirdpersoncharacter then it wouldnt ever work.

make the script like i did and have it on your enemy. then have the score on your player. the cast on the script is to get a reference to the player so that you can modify the score.

on the enemy blueprint, towards the end, how did you get the target on the Set Score node before destroy actor?

drag off the as thirdperson pin on the cast node and type set score. as long as the thirdperson bp has a variable of score it should show up.