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:
in WidgetClass:
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:
in WidgetClass:
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.
i think your BPs in GameMode right? i need to do it in PlayeController
i did same as you but there is an error. Where i lost. Please help me
in GameMode:
in Player controller:
in WidgetClass:
error is:
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.
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?
Did you check the World Outliner and make sure the widget is loaded at your level?
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.
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.
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