Checking variables

So here is question.
I need fire event “DamageWasDone” every time when var “hp” was changed. “hp” can be changed in many ways by many functions and fire event “DamageWasDone” directly from every function will be retarding. I can with “EventTick” every frame check if “hp” was changed, but it will be too hard for memory. Is where any other method to checking variables?

i think the best way of doing it was instead of “change hp in many ways” you should create a public event/function that changes the HP, and at the end of the event that changes the HP you call the “DamageWasDone” event.

in case what you want is to just want another way to call an event every time i variable is changed i don’t know any.

i usually don’t use unreal with C++, most of my code is in blueprint, in case what you’re acess your variable with “InstanceOfClass.HP” i think you won’t find a simple solution, but in case you are using “InstanceOfClass.SetHP()” you could call the “DamageWasDone” in the end of SetHP().

that’s why it’s recommended to set most of the variables private and create public (or protected or whatever) get/set, because sometimes you need to do something everytime you change a variable, and it’s easier to add this thing to the end of the set than to every time you changed the variable around your code.