# How to run Event from WidgetClass in PlayerController

**URL:** <https://forums.unrealengine.com/t/how-to-run-event-from-widgetclass-in-playercontroller/555119>\
**Category:** Blueprint\
**Tags:** unreal-engine, Multiplayer, Widget, UE4-27, question, Blueprint\
**Created:** [May 12, 2022, 3:13am UTC](https://forums.unrealengine.com/t/how-to-run-event-from-widgetclass-in-playercontroller/555119 "2022-05-12T03:13:05Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![ganbaa\_elmer](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/ganbaa_elmer/32/476547_2.png) [@ganbaa\_elmer](https://forums.unrealengine.com/u/ganbaa_elmer)\
**Post date:** [May 12, 2022, 3:13am UTC](https://forums.unrealengine.com/t/how-to-run-event-from-widgetclass-in-playercontroller/555119/1 "2022-05-12T03:13:05Z")

</div>

How to run Event from WidgetClass in PlayerController?

i mean there is Event in WidgetClass so i need to run it in Player controller?  
How to do that?

in PlayerController:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/d/d/8dd86d27a58ee05a7ad725ef1e98d3da922a44a7.png)

in WidgetClass:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/2/f/f2fbb93ebedc0b04a60b2f81898520630ed1f6d3.png)

---

<div class="post-metadata">

**Author:** ![DigitalRider](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/digitalrider/32/578422_2.png) [@DigitalRider](https://forums.unrealengine.com/u/DigitalRider)\
**Post date:** [May 12, 2022, 3:36am UTC](https://forums.unrealengine.com/t/how-to-run-event-from-widgetclass-in-playercontroller/555119/2 "2022-05-12T03:36:04Z")

</div>

Your code is halfway there. All you are missing is to call the event you created in the widget class. For instance, I created a CustomEvent in MyWidget called MyWidgetCustomEvent, and I can access it as shown.

 ![Controller](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/a/6/0a65d6b70ba7d89d11a6148132d98a9e073154dc.png)  
However, there is a catch with using the widget like this. Because we need to make sure the widget is loaded in memory before we attempt to use its function(s). In my case, I added my widget to the viewport in my level blueprint, and I instructed my controller to wait 3 seconds after its creation so I know by the time I try to access the widgetBP, it will be loaded in memory already. But this is a cheating way to do things and I would definitely opt for a more stable method for production.

---

<div class="post-metadata">

**Author:** ![ganbaa\_elmer](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/ganbaa_elmer/32/476547_2.png) [@ganbaa\_elmer](https://forums.unrealengine.com/u/ganbaa_elmer)\
**Post date:** [May 12, 2022, 3:43am UTC](https://forums.unrealengine.com/t/how-to-run-event-from-widgetclass-in-playercontroller/555119/3 "2022-05-12T03:43:06Z")

</div>

i think your BPs in GameMode right? i need to do it in PlayeController

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/4/6/04645728c3e9d82e66d99fd8a3074ff61c019e25.png)

---

<div class="post-metadata">

**Author:** ![DigitalRider](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/digitalrider/32/578422_2.png) [@DigitalRider](https://forums.unrealengine.com/u/DigitalRider)\
**Post date:** [May 12, 2022, 3:52am UTC](https://forums.unrealengine.com/t/how-to-run-event-from-widgetclass-in-playercontroller/555119/4 "2022-05-12T03:52:23Z")

</div>

The BP I show is a PlayerController.

 ![Controller](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/a/a/0aaa9107d45a51edf5d4feb2e72f4d98a81614c3.png)

---

<div class="post-metadata">

**Author:** ![ganbaa\_elmer](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/ganbaa_elmer/32/476547_2.png) [@ganbaa\_elmer](https://forums.unrealengine.com/u/ganbaa_elmer)\
**Post date:** [May 12, 2022, 4:09am UTC](https://forums.unrealengine.com/t/how-to-run-event-from-widgetclass-in-playercontroller/555119/5 "2022-05-12T04:09:30Z")

</div>

i did same as you but there is an error. Where i lost. Please help me

in GameMode:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/2/1/c21dd428f5bbd5eb7d79972bb161567283069488.png)

in Player controller:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/1/4/11434e84c7b115cfffd012bd3bd6f21a47e5370b.png)

in WidgetClass:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/6/5/365f2959ec529a8a58e76daefb4eee9e4e93d3c7.png)

error is:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/9/a/29a30e4969d47456c7bcc78d24576d570826cea2.png)

---

<div class="post-metadata">

**Author:** ![DigitalRider](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/digitalrider/32/578422_2.png) [@DigitalRider](https://forums.unrealengine.com/u/DigitalRider)\
**Post date:** [May 12, 2022, 4:30am UTC](https://forums.unrealengine.com/t/how-to-run-event-from-widgetclass-in-playercontroller/555119/6 "2022-05-12T04:30:18Z")

</div>

I think I know the reason. Because the widget you created is never loaded. You can fix this by adding these to your Level Blueprint.

 ![LevelBP](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/4/a/d4a98c43858f42852d099b4e2d9838630fc1f37f.png)

---

<div class="post-metadata">

**Author:** ![ganbaa\_elmer](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/ganbaa_elmer/32/476547_2.png) [@ganbaa\_elmer](https://forums.unrealengine.com/u/ganbaa_elmer)\
**Post date:** [May 12, 2022, 5:27am UTC](https://forums.unrealengine.com/t/how-to-run-event-from-widgetclass-in-playercontroller/555119/7 "2022-05-12T05:27:51Z")

</div>

my game needs to change levels so i think creating Widget in map is not suitable for it. Can you create widget in other places?

---

<div class="post-metadata">

**Author:** ![goderyu](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/goderyu/32/485169_2.png) [@goderyu](https://forums.unrealengine.com/u/goderyu)\
**Post date:** [May 12, 2022, 6:32am UTC](https://forums.unrealengine.com/t/how-to-run-event-from-widgetclass-in-playercontroller/555119/8 "2022-05-12T06:32:06Z")

</div>

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/e/8/3e8cb42ada62090307993dae61909473a76bb0e0.png)  
set TopLevelOnly is false, and try again.

---

<div class="post-metadata">

**Author:** ![ganbaa\_elmer](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/ganbaa_elmer/32/476547_2.png) [@ganbaa\_elmer](https://forums.unrealengine.com/u/ganbaa_elmer)\
**Post date:** [May 12, 2022, 6:50am UTC](https://forums.unrealengine.com/t/how-to-run-event-from-widgetclass-in-playercontroller/555119/9 "2022-05-12T06:50:57Z")

</div>

i added but its still same

PlayerController:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/d/71d0e61be8ffa8b7409c5c18acd12cb01c3d13f1.png)

Map:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/5/6/6568d463816bcc4193841f7ca2f815eef0ec9e0f.png)

Error:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/e/1/0e15145db4e73ab2add1dcaa340d102457dd4804.png)

---

<div class="post-metadata">

**Author:** ![ganbaa\_elmer](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/ganbaa_elmer/32/476547_2.png) [@ganbaa\_elmer](https://forums.unrealengine.com/u/ganbaa_elmer)\
**Post date:** [May 12, 2022, 6:59am UTC](https://forums.unrealengine.com/t/how-to-run-event-from-widgetclass-in-playercontroller/555119/10 "2022-05-12T06:59:15Z")

</div>

i added but its still same

PlayerController:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/d/71d0e61be8ffa8b7409c5c18acd12cb01c3d13f1.png)

Map:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/5/6/6568d463816bcc4193841f7ca2f815eef0ec9e0f.png)

Error:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/e/1/0e15145db4e73ab2add1dcaa340d102457dd4804.png)

---

<div class="post-metadata">

**Author:** ![DigitalRider](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/digitalrider/32/578422_2.png) [@DigitalRider](https://forums.unrealengine.com/u/DigitalRider)\
**Post date:** [May 12, 2022, 6:03pm UTC](https://forums.unrealengine.com/t/how-to-run-event-from-widgetclass-in-playercontroller/555119/11 "2022-05-12T18:03:11Z")

</div>

Did you check the World Outliner and make sure the widget is loaded at your level?

---

<div class="post-metadata">

**Author:** ![DigitalRider](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/digitalrider/32/578422_2.png) [@DigitalRider](https://forums.unrealengine.com/u/DigitalRider)\
**Post date:** [May 13, 2022, 3:13am UTC](https://forums.unrealengine.com/t/how-to-run-event-from-widgetclass-in-playercontroller/555119/12 "2022-05-13T03:13:19Z")

</div>

Creating a widget in the level has the benefit of easy access to everything on the map. You can create a widget every time you load a new level and that should solve the problem. That being said, I have not tried to do it anywhere else so I don’t know if there is a better location.

---

<div class="post-metadata">

**Author:** ![goderyu](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/goderyu/32/485169_2.png) [@goderyu](https://forums.unrealengine.com/u/goderyu)\
**Post date:** [May 13, 2022, 6:33am UTC](https://forums.unrealengine.com/t/how-to-run-event-from-widgetclass-in-playercontroller/555119/13 "2022-05-13T06:33:50Z")

</div>

I reproduced your error report. I’m sorry I didn’t see it clearly the first time. Your project was an RPC Demo. So I need to know more about whether the Widget is owned by each client or unique to the server.

---

<div class="post-metadata">

**Author:** ![ganbaa\_elmer](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/ganbaa_elmer/32/476547_2.png) [@ganbaa\_elmer](https://forums.unrealengine.com/u/ganbaa_elmer)\
**Post date:** [May 14, 2022, 8:24am UTC](https://forums.unrealengine.com/t/how-to-run-event-from-widgetclass-in-playercontroller/555119/14 "2022-05-14T08:24:38Z")

</div>

@goderyu its owned by each user

---

<div class="post-metadata">

**Author:** ![Fluppi393](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Fluppi393](https://forums.unrealengine.com/u/Fluppi393)\
**Post date:** [May 14, 2022, 9:12am UTC](https://forums.unrealengine.com/t/how-to-run-event-from-widgetclass-in-playercontroller/555119/15 "2022-05-14T09:12:05Z")

</div>

Have your player controller create the widget on BeginPlay (and make sure to only create it for the local player by adding a branch with IsLocalPlayerController) and store the widget in a variable of the player controller. Then you can use the variable later on to call functions on the widget

---

<div class="post-metadata">

**Author:** ![ganbaa\_elmer](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/ganbaa_elmer/32/476547_2.png) [@ganbaa\_elmer](https://forums.unrealengine.com/u/ganbaa_elmer)\
**Post date:** [May 20, 2022, 9:04am UTC](https://forums.unrealengine.com/t/how-to-run-event-from-widgetclass-in-playercontroller/555119/16 "2022-05-20T09:04:27Z")

</div>

@Fluppi393 can you show on Blueprints?
