Using Event Dispatchers to communicate variable between blueprints

Hello, I have received and take a look at your project.

It appears to me that you had set up the event call inside of a widget blueprint called “PlayerInputConsole”. However, this widget blueprint didn’t appear anywhere as it doesn’t spawn.

As your event relies on a text committed, but since I am unable to type anything anywhere, it will never be called.

So, I added BeginPlay inside of SideScrollerCharacter, and manually CreateWidget and add to the viewport.

Then, the UI you had set up has several issues:

  1. Font size was 238 without wrapped in scalebox (Why?)
  2. It covers the whole screen, so technically, it blocked everything.
  3. So I hide everything and rescale it back to a corner to test.
  4. But upon commit, you destroyed this widget.

Yes, the event indeed called, but your variable “Cube_Blueprint” is nullptr.
Calling an event on nullptr, nothing will happen. So the node didn’t fire.

and this method to send input only used once…(Why?)


To fix:

  1. You might not want to do it in the widget. Inputs aren’t received in widget unless forwarded from the controller. If you had to do in the widget, consider using SetVisibility to “HitTestSelfInvisible” rather than “Remove from viewport”.

  2. You need to fetch the world object in your widget using Set node. By default, they are nullptr if you just declare a type of “Cube_Blueprint”. You probably need the character to do a “GetActorOfAllClass” for now, and get the type of the object you want, and get the first one outta that array. Then, store a cache in your character blueprint. Then, go into the widget, use “GetOwningPlayerPawn”, cast to SideScrollerCharacter, then drag the pin from it to get the cached variable. By doing this, you are forwarding the cube object from the world → character → widget.

Hope this explanation would help.