What's the cheapest, most efficient way for Character - Widget communication?

So I’m a little confused on how to do this in the best way possible. How is it best done ?
-Casting and binding values.
-Casting and local widget binding values.
-Interface running every frame with localized widget variables.
-Event dispatchers running every frame / only when when the value needs to be updated.
What’s the best method out of all these four and if you know better ones then please go ahead and state them.
Thanks!

Only running when values change is obviously going to demand less CPU than running every frame but you gotta ask yourself if it is worth adding the complexity for this. It probably is since debugging is also easier when things run less frequently.

If you choose casting you should consider if a soft reference is better. A normal cast will load the widget along with the character so if you have many types of widgets it would be better to use a soft reference and only load the widget when needed.

With an interface you decouple the character from the widget but unless if you need the interface across several different classes it might be easier to just use a soft reference and keep the direct relationship between character and widget.

Event dispatchers are great for avoiding circular dependencies. If the widget is interact-able each interaction should be made with Event Dispatchers on the Widget and the Character can bind to it.

Finally you should not dwell too long on which nodes you should avoid but rather use the profiler frequently when testing to find the worst offenders and spend time on those. Chances are only 10% of your blueprints are spending 90% of your CPU so focus on those and keep the rest easy to work with.

1 Like