# What is the best approach to refresh / rebuild widget's event construct?

**URL:** <https://forums.unrealengine.com/t/what-is-the-best-approach-to-refresh-rebuild-widgets-event-construct/227912>\
**Category:** Blueprint\
**Tags:** unreal-engine\
**Created:** [May 5, 2021, 2:49pm UTC](https://forums.unrealengine.com/t/what-is-the-best-approach-to-refresh-rebuild-widgets-event-construct/227912 "2021-05-05T14:49:58Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![SoulforgedCRO](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SoulforgedCRO](https://forums.unrealengine.com/u/SoulforgedCRO)\
**Post date:** [May 5, 2021, 2:49pm UTC](https://forums.unrealengine.com/t/what-is-the-best-approach-to-refresh-rebuild-widgets-event-construct/227912/1 "2021-05-05T14:49:58Z")

</div>

The game I’m working on has collectables (“CollectableBP”). PlayerHUD is loading “CollectablesIndicator” widget which should update text if the certain criteria upon pickup is met.

Example: “You don’t have enough items X”, “You need one more item X”, “You have all the items you need”.

I’m currently using EVENT TICK (instead of event construct) inside my widget’s blueprint, because it constantly triggers the widget’s logic. It is working great but I’m aware that this is not the right approach. I would like to make my CollectableBP communicate with the widget upon the actual item pickup, not every second.

What is the best approach to refresh / rebuild widget’s event construct through my CollectableBP?

Thanks!

---

<div class="post-metadata">

**Author:** ![Pantoth](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/pantoth/32/1194538_2.png) [@Pantoth](https://forums.unrealengine.com/u/Pantoth)\
**Post date:** [May 5, 2021, 3:18pm UTC](https://forums.unrealengine.com/t/what-is-the-best-approach-to-refresh-rebuild-widgets-event-construct/227912/2 "2021-05-05T15:18:15Z")

</div>

Most of the time the answer on this question is: Event Dispatcher. To be honest, I’ve never used it until now, but as far as I can tell, it’s like the Widget is listening for events - triggered by the CollectableBP.

I think it’s well explained here:

> [@Event Dispatchers explained - Finally!](https://forums.unrealengine.com/t/event-dispatchers-explained-finally/55570):
>
> Ever since I started working on Unreal Engine 4, I have come across a few roadblocks from time to time which have no solutions on the internet or the official documentation. ‘Event dispatchers’ was one of them and the official documentation regarding the topic is really vague to say the least. So, after a lot of experimentation with Event Dispatchers, I am writing this post where I will try to explain as clearly as I can about Event Dispatchers and why it should be used. So lets begin! [Also, n…

---

<div class="post-metadata">

**Author:** ![SoulforgedCRO](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SoulforgedCRO](https://forums.unrealengine.com/u/SoulforgedCRO)\
**Post date:** [May 5, 2021, 3:23pm UTC](https://forums.unrealengine.com/t/what-is-the-best-approach-to-refresh-rebuild-widgets-event-construct/227912/3 "2021-05-05T15:23:01Z")

</div>

While I was researching on how to solve my problem, I’ve stumbled upon event dispatchers but I was unable to find a “normal” and beginner friendly tutorial on YouTube. I’ll definitely check this link out.

Thanks!

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [May 5, 2021, 3:34pm UTC](https://forums.unrealengine.com/t/what-is-the-best-approach-to-refresh-rebuild-widgets-event-construct/227912/4 "2021-05-05T15:34:24Z")

</div>

To clarify, is this how it’s supposed to work:

- the player creates the hud widget
- the player runs into a pickup actor
- the hud widget gets updated

How close am I?

Anything else we need to know about? As in, the pickup actors are spawned dynamically as we progress through the game? Or there’s a limited amount placed in the level manually?

* * *

Atm, the widget is pulling the data from the player on Tick, correct?

---

<div class="post-metadata">

**Author:** ![SoulforgedCRO](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SoulforgedCRO](https://forums.unrealengine.com/u/SoulforgedCRO)\
**Post date:** [May 5, 2021, 3:52pm UTC](https://forums.unrealengine.com/t/what-is-the-best-approach-to-refresh-rebuild-widgets-event-construct/227912/5 "2021-05-05T15:52:48Z")

</div>

1. Player HUD + widget are loaded on startup
2. Collectables are dynamically spawned across the level (“CollectableBP”)
3. Upon a pickup → pickup values are stored (as booleans / integers) inside ThirdPersonCharacter blueprint → actor is destroyed (inside “CollectableBP”)
4. “CollectablesIndicator” widget blueprint handles the logic and updates the display

**My goal is to connect steps 3 and 4.**

**CURRENTLY** - the widget is using EVENT TICK which constantly checks for booleans / integers values and updates the display via text transform.

**IDEALLY** - “CollectableBP” would “ping” the widget after destroying the actor so that the widget could recalculate and refresh the display via text transform.

I want to avoid using event tick if I can.

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [May 5, 2021, 4:01pm UTC](https://forums.unrealengine.com/t/what-is-the-best-approach-to-refresh-rebuild-widgets-event-construct/227912/6 "2021-05-05T16:01:32Z")

</div>

> [@SoulforgedCRO](#):
>
> Player HUD + widget are loaded on startup

But which blueprints creates this widget? The player? While you absolutely can use a dispatcher for this, there may be no need.

Player runs into the pickup and updates its own hud widget. Basic direct comms would be more than enough here.

If the widget is created by the Game Mode for example, and thus is unrelated to the player blueprint, a dispatcher will be a better solution.

> [@SoulforgedCRO](#):
>
> **IDEALLY** - “CollectableBP” would “ping” the widget after destroying the actor so that the widget could recalculate and refresh the display via text transform.

What you call Ideally may not be that perfect. Generally speaking, it’s the player that should handle the counting and the widget should be displaying what the player has counted. The fewer elements there are in the widget, the better.

Lemme demo something crude real quick.

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [May 5, 2021, 4:08pm UTC](https://forums.unrealengine.com/t/what-is-the-best-approach-to-refresh-rebuild-widgets-event-construct/227912/7 "2021-05-05T16:08:23Z")

</div>

The stuff:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/3X/2/5/2510f95669956847eaa32cc3f1b79e87160ee061.jpeg)

The player picking stuff up:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/3X/2/e/2e79d15bf405b6b2cb3b2129e6866ed317358fa8.jpeg)

In this case, the player creates the widget and shows it. When the player runs into a collectible, we count it and set the widget’s text to that value. Here the widget was updated 4 times.

---

<div class="post-metadata">

**Author:** ![SoulforgedCRO](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SoulforgedCRO](https://forums.unrealengine.com/u/SoulforgedCRO)\
**Post date:** [May 5, 2021, 4:08pm UTC](https://forums.unrealengine.com/t/what-is-the-best-approach-to-refresh-rebuild-widgets-event-construct/227912/8 "2021-05-05T16:08:51Z")

</div>

Player\_HUD (HUD) creates the collectables widget and ads it to the viewport upon event begin play.

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [May 5, 2021, 4:10pm UTC](https://forums.unrealengine.com/t/what-is-the-best-approach-to-refresh-rebuild-widgets-event-construct/227912/9 "2021-05-05T16:10:43Z")

</div>

> [@SoulforgedCRO](#):
>
> Player\_HUD (HUD) creates the collectables widget and ads it to the viewport upon event begin play.

So what is Player\_HUD - another widget? The HUD class? Just trying to wrap my mind around it. The player HUD widget creates another widget - the Collectible widget?

---

<div class="post-metadata">

**Author:** ![SoulforgedCRO](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SoulforgedCRO](https://forums.unrealengine.com/u/SoulforgedCRO)\
**Post date:** [May 5, 2021, 4:12pm UTC](https://forums.unrealengine.com/t/what-is-the-best-approach-to-refresh-rebuild-widgets-event-construct/227912/10 "2021-05-05T16:12:49Z")

</div>

It is HUD class.

I have tried creating the widget and adding it to the viewport from the CollectableBP after actor destroy event and it worked but it loaded one widget over another instead of updating it.

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [May 5, 2021, 4:19pm UTC](https://forums.unrealengine.com/t/what-is-the-best-approach-to-refresh-rebuild-widgets-event-construct/227912/11 "2021-05-05T16:19:17Z")

</div>

- the HUD class creates the collectible widget:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/3X/a/3/a330e1576d64cbe23d0c1b94419ed996a2a462ef.png)

- the player runs into a collectible actor, gets access the HUD class and updates the widget

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/3X/3/a/3a639848b6f362b01d64ee843ebe8a907d44e078.jpeg)

The above can be made better by having a custom event in the HUD and calling that.

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [May 5, 2021, 4:24pm UTC](https://forums.unrealengine.com/t/what-is-the-best-approach-to-refresh-rebuild-widgets-event-construct/227912/12 "2021-05-05T16:24:46Z")

</div>

> [@SoulforgedCRO](#):
>
> Collectables are dynamically spawned across the level (“CollectableBP”)

If you’d like to see an example taking advantage of an Event Dispatcher handling it, do tell. What spawns the collectibles?

* * *

If you wish the player knew nothing about the collectibles and prefer they talked directly to the HUD’s widget when they’re picked up, it can be arranged, too. Not a bad approach for a game where there are multiple characters.

---

<div class="post-metadata">

**Author:** ![SoulforgedCRO](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SoulforgedCRO](https://forums.unrealengine.com/u/SoulforgedCRO)\
**Post date:** [May 5, 2021, 4:50pm UTC](https://forums.unrealengine.com/t/what-is-the-best-approach-to-refresh-rebuild-widgets-event-construct/227912/13 "2021-05-05T16:50:06Z")

</div>

Wow! This example is amazing! I’ll definitely try the Cast to Player\_HUD (with widget/text-block) approach! Thanks!

As for event dispatcher, it would be amazing to see how that works as well. I’d like to learn about Unreal as much as I can, so I always find interest in different approaches. 🙂

Collectables are spawned through SpawnerBP - it is manually placed on multiple locations across the level and it has a chance to spawn multiple collectable types or to spawn nothing.

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [May 5, 2021, 5:27pm UTC](https://forums.unrealengine.com/t/what-is-the-best-approach-to-refresh-rebuild-widgets-event-construct/227912/14 "2021-05-05T17:27:30Z")

</div>

The idea behind Dispatchers is that one actor calls it and another actor receives that call. It makes it somewhat easier if you think about it as broadcasting and listening. Actors broadcast (call dispatchers) and other actors _can_ listen to those calls. Actors that don’t listen cannot react to those calls.

In this instance the HUD class will listen to the Collectible actors’ calls.

Interestingly enough, actors already come with a bunch of dispatchers. You can add your own custom ones, but it’s not necessary here. Since the collectibles are getting Destroyed, we’ll use that.

> **IDEALLY** - “CollectableBP” would “ping” the widget after destroying the actor so that the widget could recalculate and refresh the display via text transform.

## The HUD class:

- (top) create the widget and set it up

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/3X/c/a/caf1d1774d60721e62b06c3d3557c97f1ffc76f3.jpeg)

- (bottom) A _Custom Event_ with an Actor input - the input is required here as matching signatures on Dispatchers is a thing. When this event is called, it will update the text in the widget. Think of this element as the listening bit - it will listen to the collectible actors getting Destroyed.

## The collectible actor:

- (top) at Begin Play, aCollectibleBP registers its own (self) dispatcher call (_Bind Event to On Destroyed_) with the Custom Event in the HUD (pic 1).

- Actors already broadcast their own destruction, but hardly anyone listens :(. Now the HUD will be notified when it happens and that

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/3X/d/d/ddc821e7f784e71f46ce4578ea1ec6e9cdbbbb5c.jpeg)

- (bottom) when the collectible detects the player, it Destroys itself.

In short, collectibles getting destroyed call a custom event in the HUD.

* * *

There is no script in the player blueprint. Technically, the player does not even know about it.

---

<div class="post-metadata">

**Author:** ![Pantoth](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/pantoth/32/1194538_2.png) [@Pantoth](https://forums.unrealengine.com/u/Pantoth)\
**Post date:** [May 5, 2021, 5:50pm UTC](https://forums.unrealengine.com/t/what-is-the-best-approach-to-refresh-rebuild-widgets-event-construct/227912/15 "2021-05-05T17:50:08Z")

</div>

@Everynone Thanks for that neat example! The time will come where I’ve to use a Dispatcher myself 🕶

---

<div class="post-metadata">

**Author:** ![SoulforgedCRO](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SoulforgedCRO](https://forums.unrealengine.com/u/SoulforgedCRO)\
**Post date:** [May 5, 2021, 5:59pm UTC](https://forums.unrealengine.com/t/what-is-the-best-approach-to-refresh-rebuild-widgets-event-construct/227912/16 "2021-05-05T17:59:27Z")

</div>

Amazing! Thanks!

I’ll give both approaches a go and fork my project.

---

<div class="post-metadata">

**Author:** ![SoulforgedCRO](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SoulforgedCRO](https://forums.unrealengine.com/u/SoulforgedCRO)\
**Post date:** [May 5, 2021, 6:25pm UTC](https://forums.unrealengine.com/t/what-is-the-best-approach-to-refresh-rebuild-widgets-event-construct/227912/17 "2021-05-05T18:25:40Z")

</div>

I’ve successfully implemented your first solution. 🙂 No more event tick. Well, no more widget blueprint. 🙂

Thanks!

I’ll try the dispatcher tomorrow as well.
