Run Custom Event of other BP via Widget Button?

I have a Widget with a button on it. When I click the button I would like to run a Custom Event from the “Blueprint_Test” class. But I have no idea what to put in the target.

This is my “Blueprint_Test” class.

Normally I would create a public variable of “Blueprint_Test” in my Menu Widget.
But then I get a “Accesed None” error. Becouse I have to assign the Blueprint_Test to the variable in the “Details” panel of the object. But since this is a Widget it is not placed in the scene. It is created in the scene via a different object with the “Create Widget” node. So I can not drag Blueprint_Test in to the variable.

It is probarly something very easy but it can take me days to solve this.

Hope someone knows the solution.

It is and isn’t at the same time.

Can you tell where / when the widget is created and how the actor that is supposed to receive the call makes it into the world?

Or, perhaps, you can share a bit more. Is it always going to be 1 widget and 1 actor? Or it will get more complex?

It is created in the “UI_Manager” Blueprint

It is just for some prototyping. I have a Unity background and worked with Unity Visual Scripting. I am trying to transfer from Unity in to Unreal. And I am trying some communication between different elements.

The UI Manager is an actor that sits in the scene, got it.

And the other actor - the test actor? I see it, also in the scene. Gimme a sec.

1 Like
  • the UI Manager actor that creates and references the widget - this variable is important:

You can right click any pin and promote it. You can then use that reference to manipulate an object.

  • test actor:

image

  • each level has a Level Blueprint that can directly reference actors in the scene:

  • Since we have both references in one place now:

Whenever a button is pressed in the UI Manager’s widget, we fire an event in a test actor.


There’s no other script, this is not necessary for example:

thank you for the fast repsonse and clear explenation. I see that in Unreal Engine a lot of stuff is done in the Level Blueprint. In Unity I try to keep things seperated as much as possible. For example: UI_Manger, Audio_Manager, Input_Manager, Score_Manager etc etc…

This kind of stuff is mostly done in the level blueprint?

I see that in Unreal Engine a lot of stuff is done in the Level Blueprint. […]
This kind of stuff is mostly done in the level blueprint?

On the contrary, ideally you’d never use it. But since you’ve placed your actors in the scene… that’s the easiest way to go about it. Level Blueprint has its uses. If you want to tie some mechanics to one level and one level only, you can then use its blueprint.

You can create a complex project without ever opening the LB.


UE4 has a framework, a bunch of dependant classes:

These are the places where one can create and reference manager actors. Framework is accessible from (almost) anywhere.


Perhaps this will be handy:

“Perhaps this will be handy:”
Yes deff. I have it as bookmark on my chrome browser.

I will look up the Gameplay Framework.

I would like to avoid the Level Blueprint as much as possible as I want to have things modular.

I have been doing more research to casting and I notice that Interfaces are a more easy way to do custom event. Am I right?

I would actually like to create this outside the level blueprint.

There are three methods of communications in UE:

  • Direct: you’ve already obtained an object instance reference of the correct type:

For example, we can actually pick it from the scene and have the UI Manager talk to that actor instance directly.

  • or Direct + Cast: you’ve already obtained a reference to the object instance, and think you know the type or expect a type, or want to test something:

Casting is great, and inheritance is indispensable.

  • Interface: you’ve got a reference but you do not know the class, think projectile hitting something, anything:

image

We’ll send the target a message, if they implement the interface and have the functionality, they can deal with the message any way they want. Casting still happens here but it’s hidden under the hood.

  • Event Dispatchers: you have the reference now, but want talk to the actor later, or want the delegate sent to another actor:

You will need all of them, use all of them, often together. They’re circumstantial and situational. None is better than the other. You choose the best tool for the job.


I would actually like to create this outside the level blueprint.

First example above. Direct comms. No casting, no level blueprint. One to one chit chat.

Namely:

Widget buttons have a bunch of dispatchers already (so do other widgets and actors). Widget talks to the UI manager through a dispatcher and the UI manager directly asks the Test Actor instance to rotate.

I am going to take some time to look at your post and experiment with it myself.
I have to give props for the Unreal Forum feedback time. Have posted more questions last week and all of them were answered quite fast.

1 Like