Download

Simple Enemy HP Widget gives me Accessed None

Hello everyone! Faced with a new (but very simple problem). I successfully created a widget with my health for the player. However, I can’t do the same for NPCs, although they are essentially exactly the same, the only difference is that for the player I display the Widget UI on the screen, and in the case of a monster above his head in the widget component.

Variables are set. However, if everything works for a player, it doesn’t work for an NPC. Error on last screenshot.

I read about it and everything indicates that the variable is not set, but it is set. What am I doing wrong?

Maybe i should cast to this widget or something?

It works on the player because you are using GetPlayer(!!)Character. In the enemy blueprint store his health widget, and when he takes damage call a function on this widget that sets the percentage. You can give the
​​​function input parameters to make your life easier.