How to count the death of a AI

Hi,

In my AI BP I’ve setup so each time the actor destroys a value of 1 will be added to a variable called “Deathcount”. But this value only stays at it’s initial value of zero despite the actors destruction during gameplay.

The variable is public and I’m using a print node in the level BP to see if the value changes but it does not.

What am I doing wrong here?


Hm ok, normaly your reference stays 60 seconds. After that, it will be destroyed.
That means, even if you manage to change the variable, it will get lost after
60 seconds.

How about saving this in the GameState class for example? I don’t know if you
want to count it for every AI sperated, but this will also be possible.

Try creating the variable in another persisten Class and BEFORE you destroy the
AI, change this variable by getting the Class (you can also save it before as a ref
and than use it) and changing it than.

What i do, is i have a score blueprint that i cast any scoring activities into. so something along the lines of Get all actors of class Score, Get Score, Cast to Score, Get Int ScoreTotal from Score, Set Int ScoreTotal to ScoreTotal + 1.