From widget BP to Level BP with a BP interface

Hello Mates,

I am trying to make a directional light (the sun) move to position when the player click on an icon in a menu.

I created a BP interface with a morning function and from my Widget BP I would like to call the function morning to transmit it to a Level BP which will set the new rotation of the directional light but…
The event message node need a target input and if a create a variable actor type I cannot select the level as default value…
So how to select the level in the variable or transmit the info to the level BP?
If you can point out a solution, that will be nice :slight_smile:

1 Like

You can’t talk to the level BP with interfaces, you need to use an event dispatcher:

Thank you for pointing this out
Then I follow several tutorials about event dispatchers including the one you mentioned.

There is also this short tutorial here

Really benefited from this question. I too needed to access the level but couldn’t.
Turns out I did need to use the event dispatcher, so had to learn how they work.
I’d had one from a previous tutorial but didn’t really understand it but now I do.

Here was the scenario:
I have a weapon that shoots a line trace into a moving target in the level. When I get a pituitary kill shot on the moving target, I want that to trigger the activation of a different kind of random target already placed throughout the level.

The problem with the weapon for an event dispatcher is that they like things that are there from the beginning of the game. My weapon isn’t spawned until I pick it up so not good for that.

So, from the weapon I called a custom event in the Character Blueprint (which is always there). Then from that custom event, I called the Event Dispatcher.

Then, in the level I bound the casting of the character (which happens on load) to the event in the level.

Called from Weapon:

Character Event:
ED is created and held ONLY in Character:

Level Load:

Curious how the Character is being created?

Is it already placed in the level, is it spawned automatically, or is it spawned manually? Just questioning if some unfortunate timing sometime could ever break that code. Such as in a shipping or packaged build where timing can be different / startup order can change.

Overall, it might be safer to pivot off one of the core game classes such as Gamemode and add the ED there instead, or add a Delay to the Level BeginPlay code to make sure the Character gets created in time on slow rigs or if the game code grows / is more complex. :wink: