How to send data from actor component to widget, without hard referencing?

Once you create that widget, it’s going to need a hard pointer to that actor component to pull data from initially. You don’t have to store the pointer though, if you set up the widget to pull data from the actor component by delegates (event dispatcher in blueprint).

Widgets work well like that, using the observer pattern to automatically respond in changes to data (to reflect them on the UI), without having to constantly check for changes or store pointers separately.

https://www.youtube.com/watch?v=ayCEqL7XFZY

soft / hard pointers etc don’t decouple. Soft is used to optimize what loads into memory and when. Hard (UObject*, TObjectPTR) loads into memory immediately. Both still need to reference a class in your case because the widget needs to find that struct property on your custom actor component. So that doesn’t decouple.

All about Soft and Weak pointers | Tutorial

1 Like