Widget world/screen space issue

I have a Widget component which is attached to a Pawn. The Widget is set to screen space and appears over my pawns as they move around in the world. My world is moving very quickly, so when my pawns are killed, the widget stays with them and flies off screen. What I want is for the widgets to become dettached somehow at the point of death so they can finish their messages in vision of the player. I’d though that if I just detached the widget component from the Pawn, that it would remain where it was in screen space. That doesn’t seem to be the case.

Does anyone have any suggestions for how I might achieve this?

Components have ownership and, someone corrects me here if I’m wrong, you cannot change it via blueprints. Once the owning actor gets destroyed, it takes the component down with it as well. You can detach and attach to something else but the ownership does not change.

I can see 3 solutions here:

  1. Detach the component at the time of "death", this will stop the onscreen position getting updated. *Death *in this case would simply mean hiding the actor long enough to deliver the message to the player. Once sufficient time has gone past, destroy the actor for good.

  2. You can gain access to the embedded 2d widget in the Widget Component with the *GetUserWidgetObject *node. Once you have the widget reference, add it to the viewport at the Widget Component’s screen space location. Now, the widget in the viewport is being referenced by it, preventing garbage collection from destroying it. The original actor can now die in peace and take the Widget Component with it for all you care. This approach will require you to keep track of the widgets references added to the viewport since you will want to get rid of them eventually, too.

  3. Do not use Widget Components for this. Dynamically spawn normal 2d widgets for each pawn and update the onscreen location somewhere so they follow their pawns. Now it does not matter if the Pawns are alive or not. Your widgets sit in the viewport anyway.

Thanks for you advice. I’d actually taken a couple of those steps already but you gave me the missing puzzle pieces. Cheers!


For anyone following, I ended up detaching my widget component from the pawn and attching it to the scene component of another actor that was moving along with everything else. It gave me the effect I was looking for.