# Are there any events that are called AFTER Begin Play

**URL:** <https://forums.unrealengine.com/t/are-there-any-events-that-are-called-after-begin-play/2014410>\
**Category:** Programming & Scripting\
**Tags:** tick, beginplay, unreal-engine, Event, CPP, Blueprint, question\
**Created:** [September 10, 2024, 9:31am UTC](https://forums.unrealengine.com/t/are-there-any-events-that-are-called-after-begin-play/2014410 "2024-09-10T09:31:39Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Untiziotizio](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Untiziotizio](https://forums.unrealengine.com/u/Untiziotizio)\
**Post date:** [September 10, 2024, 9:31am UTC](https://forums.unrealengine.com/t/are-there-any-events-that-are-called-after-begin-play/2014410/1 "2024-09-10T09:31:39Z")

</div>

Hi.  
I’ve already posted two posts regarding a specific problem that I’ve been facing for days without any solution:

- [I don’t get how Delegates / Events works on Unreal Engine](https://forums.unrealengine.com/t/i-dont-get-how-delegates-events-works-on-unreal-engine/2006257/6)
- [UE5 C++ event doesn’t fire](https://forums.unrealengine.com/t/ue5-c-event-doesnt-fire/1988720)

But now after days of debugging the whole code I think I’ve found where the problem is.

So basically I have an **HealthComponent (C++)** that fires a **Delegate** everytime the Health is set: **OnSetHealth**. The listener of this delegate is in my WBP\_HUD, that is a **Widget Blueprint** , because I want to update the Health Bar every time the event is fired.

Ideally I would broadcast the delegate in Begin Play like this:

```auto
void UHealthComponent::BeginPlay()
{
	Super::BeginPlay();

	SetHealth(MaxHealth);
}
void UHealthComponent::SetHealth(const int Value)
{
	CurrentHealth = FMath::Clamp(Value, 0, MaxHealth);
	OnSetHealth.Broadcast(MaxHealth, CurrentHealth);
}

```

while this is the logic inside the WBP\_HUD:

 ![Screenshot 2024-09-10 104149](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/a/0/ca07b4a52f154788b5604679f0bffb7a9563517a.png)

The problem is that Begin Play is always called BEFORE any WBP event like On Initialized or Event Constructor, because they get called AFTER the UI has been displayed, which means it doesn’t bind the event in time.

One work around that I’ve found was broadcasting the delegate in the Tick event just for the first frame, but this obviously seems pretty _Spagetti code_:

```auto
void UHealthComponent::TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
	Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
	if (bFirstTick)
	{
		SetHealth(MaxHealth);
		bFirstTick = false;
	}
}

```

So for this reason I’m asking if there’s any event that are called after Begin Play

---

<div class="post-metadata">

**Author:** ![Auran131](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Auran131](https://forums.unrealengine.com/u/Auran131)\
**Post date:** [September 10, 2024, 9:39am UTC](https://forums.unrealengine.com/t/are-there-any-events-that-are-called-after-begin-play/2014410/2 "2024-09-10T09:39:04Z")

</div>

i mean you could create you own Event but i dont think thats the point.

I think your problem here is load order and you’ll encounter this alot, what you should do is just control it somewhere, ie the PlayerController spawns the pawn and the creates the widget so you know the pawn exists when the widget is created

---

<div class="post-metadata">

**Author:** ![Untiziotizio](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Untiziotizio](https://forums.unrealengine.com/u/Untiziotizio)\
**Post date:** [September 10, 2024, 9:48am UTC](https://forums.unrealengine.com/t/are-there-any-events-that-are-called-after-begin-play/2014410/3 "2024-09-10T09:48:02Z")

</div>

So you think that I should create my own PlayerController and load the UI and the Pawn at the same time? Wouldn’t Begin Play still get called before the UI is loaded? This seems very odd as a work around but I’ll try it

---

<div class="post-metadata">

**Author:** ![Auran131](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Auran131](https://forums.unrealengine.com/u/Auran131)\
**Post date:** [September 10, 2024, 9:51am UTC](https://forums.unrealengine.com/t/are-there-any-events-that-are-called-after-begin-play/2014410/4 "2024-09-10T09:51:38Z")

</div>

i’d say this is standard practice,  
the problem as you’ve identified is you just don’t know when BeginPlay will fire, worse it can change between PIE and Standalone breaking your project and can be hard to track down.

consider my way like a load screen, you load all the things you need in the order they require and so it will always work.

---

<div class="post-metadata">

**Author:** ![Auran131](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Auran131](https://forums.unrealengine.com/u/Auran131)\
**Post date:** [September 10, 2024, 9:53am UTC](https://forums.unrealengine.com/t/are-there-any-events-that-are-called-after-begin-play/2014410/5 "2024-09-10T09:53:10Z")

</div>

another advantage to this is you can pass the newly created pawn/component straight to the UI and not have to Get/Cast IF that’s the design you want

---

<div class="post-metadata">

**Author:** ![Untiziotizio](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Untiziotizio](https://forums.unrealengine.com/u/Untiziotizio)\
**Post date:** [September 10, 2024, 11:22am UTC](https://forums.unrealengine.com/t/are-there-any-events-that-are-called-after-begin-play/2014410/6 "2024-09-10T11:22:53Z")

</div>

Well I’m not familiar with custom Player Controllers. Can you show an example of how to do it?

---

<div class="post-metadata">

**Author:** ![Auran131](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Auran131](https://forums.unrealengine.com/u/Auran131)\
**Post date:** [September 10, 2024, 12:01pm UTC](https://forums.unrealengine.com/t/are-there-any-events-that-are-called-after-begin-play/2014410/7 "2024-09-10T12:01:54Z")

</div>

you can create one the same as any class in the NewBlueprintClass menu or in c++ just inherit from APlayerController

then in your world settings/gamemode change the default controller class to your class and default pawn to none as you will spawn your own.

on controller begin play spawn the pawn and possess
