Health bar doesn't update unless I hover over again

Hello! I am new to this, so please be gentle.

I have created a widget (called Actor Health) that display the actor’s health when I hover over it, and removes the widget when I move my cursor away. I have created an ActorOnClicked event that deals damage when I click the actor. Now, the problem is that the widget doesn’t update when I deal damage, it only updates when I re-create the widget by moving my cursor off the actor and over it again. Can someone help me fix it, so that the widget updates correctly? The health bar display’s the health just fine, it just doesn’t update in real-time.

Both pictures are from same blueprint. I have done all this on a parent actor, then I spawn childs of this actor in the level script when I hit play. Everything works perfectly, except for that the health bar doesn’t update properly. Hopefully my comments are correct, that I have understood my own scripting correctly

image

image

Ok, I managed to narrow it down to that Current Health doesn’t update after I add the widget to the viewport. I have no idea how I should update Current health afterwards. I have tried event ticks and delays, but nothing has worked so far.

Ok, so I suspect that the issue is not so much in your code, but in your widget. So one thing I always do with my widgets that display information about an object is I create a reference to that object and set it when I spawn the widget. I usually call this variable “Control”.

Then in your widget you can bind the value of, say a text field, or whatever to an event. And in the event I just link it to “Control” and pull the variable out of there. So for instance if I wanted my widget to display a percentage of health on a character I would have my textfield be bound to an function and this function would be hooked up to “Control” → CurrentHealth / “Control” → MaximumHealth. I hope this makes sense and helps you out.