Interface Message Not Heard by UI Blueprint

Hi everyone, I’m seriously going crazy trying to figure this out, if you help me I will appreciate you for the rest of my life.

Short version: My UI Widget Blueprint does not hear messages from an interface, while my Pawn blueprint does everything the same and can hear messages from the same interface no problem.

Long version:
I simplified this as much as possible.

I have an actor called BP_Actor.
image

I have a pawn called BP_PlayerCamera.
image

I have a User Widget called BP_HUD.
image

I have a HUD blueprint called BP_HUD2.
image

I also have an Interface called BPI_Activate.
image

These Blueprints are set up properly in my world settings:
image

BP_HUD2 gets loaded and draws the BP_HUD on the screen, no problem:

This draws the HUD and everything works fine.

BPI_Activate has a function called “In_TestFunction”:
image

BP_Actor has a cube, and when this cube gets clicked, it sends a message to “In_TestFunction” through BPI_Activate (which it has added as an interface in its Class Settings):
I added a node pair for both HUD, and Camera, just to be sure both will receive this:

In BP_Actor’s variables:
The “TargetCamera” variable references BP_PlayerCamera
The “TargetHUD” variable references BP_HUD
image

The Class Settings in BP_Actor has BPI_Activate added as an interface:
image

Now, when I go into BP_PlayerCamera, I have everything I need for this pawn to receive messages from BPI_Activate.

I have the BPI_Activate added as an interface in Class Settings:
image

I have a variable referencing BP_Actor:
image

And I’m able to add an event based on messages received from BPI_Activate:
image

This works, and it prints the message.

HOWEVER, the problem is in BP_HUD.

I’ve done the same things in BP_HUD as I did in BP_PlayerCamera to be able to hear messages:
1: I’ve added BPI_Activate interface in Class Settings:
image

  1. I have a variable in BP_HUD that references BP_Actor:
    image

  2. I add an event based on messages received from BPI_Activate:
    image

But THIS, does NOT work. It does not print the message on screen.

Even though in BP_Actor, you can see the message is sent first to BP_HUD, and only afterwards
to BP_PlayerCamera. But the former doesn’t get the message, while the latter does:

This is driving me crazy. Why can a Pawn blueprint hear the interface but a User Widget blueprint cannot?

At this point I’m NOT trying to solve the problem, I’m trying to understand how and why Unreal Engine does things a certain way. So please don’t suggest alternative ways of solving my problem, I’m just looking to understand why this particular setup doesn’t work.

But…, I think you must use just one BP_HUD from Gamemode.

Hi, thanks for replying. My GameMode only has available options for HUD2:

(There’s also the default “HUD” option but I don’t want to use this, I want to create my own.)

I load HUD2 from GameMode:
image

…and use it to get BP_HUD drawn (the below is inside BP_HUD2)

And BP_HUD indeed does get drawn and does work. I even got BP_HUD to display some dynamic stuff to make sure it’s working.

Also, my question applies to BP_HUD2 as well anyway. I add the same function call to BP_HUD2 and it also doesn’t print anything.

So for example if I use BP_Actor to send a signal to BP_HUD2 like this:
image

(TargetHUD2 variable in this case pointing to BP_HUD2)
image

And in BP_HUD2 call my print text action:
image

This ALSO doesn’t print anything.

Can you show us how your Target_HUD and Target_HUD2 variables are being set?

While looking at what you said I discovered something. First let me answer your question:

TargetHUD variable:
image

Details:

TargetHUD2 variable:
image

Details:

What I realized is this:

In the “Details” window for “TargetHUD” (referencing BP_HUD which is what includes my actual HUD)
there is a section that says “Default value”, and when I set this to “BP HUD” it actually worked:

This is interesting, I would like to understand why this works.

For example, when I look TargetHUD2 (the variable for BP_HUD2), this value cannot be selected:

be careful confusing
HUD which is a Widget
and HUD2 which is a HUD class.

you probably dont need HUD class anymore you can create HUD widgets in your player controller but up to you.

either way Create the hud widget save the return value to a variable and call your interface functions on that variable

So is there a fundamental difference between what you can do with a Blueprint of a HUD Widget type versus the Blueprint of, say, an actor type?

If yes, then do you have any resources that I can read up on that talk about the functional differences between Blueprint types?

From this experience I’m suspecting that not all Blueprints are created equal, but it’s not immediately clear to me which Blueprint type can do what.

Thank you all for replying. This is a great community! I’m looking forward to the day when I can be of help to others like you folks have been to me.

Honestly, I do believe you are missing some general concepts here. I don’t see in your screenshots any variable assignments. So what you possibly do is calling your interface methods on uninitialized (null) variables. In Unreal Engine this is perfectly fine and will not result in any error, it will simply not do anything.

This is how it normally looks like:

What I just learned is that you can assign default values to Widget variables, just like you did. So you can ommit the first 2 nodes from my example as the widget is already being created and properly assigned.

Since you also created a Widget in your BeginPlay, you should actually end up with 2 widget objects. One that is automaticcaly created and assigned to the BP_HUD2 variable (which you called the method on) and one that is not assigned to any variable but is added to the viewport. You can confirm that assumption by doing something visible in the BP_HUD2 InTestFunction. Like changing a text of a label or adjusting a background color. You shouldn’t be able to see any change now, as the changes happens to a widget which is not on the screen.

Thank you for replying. I think you’re right - After this issue I’ve also had another issue with Actor references for example. It seems my problem is mostly about the object references in the variables not being able to find the object I’m trying to point to.

Turns out that when you’re in a blueprint and you assign a variable pointing to another object’s reference, sometimes these references return NULL (even though in my case most of these objects are either placed on the level in the Editor to begin with). Without knowing much about how Unreal Engine does things on the backend, I found a few more threads and it seems like this has something to do with some assets being created at runtime and some variables being unable to get assigned to the actual objects being created in runtime, so they come up NULL.

In the case of Interface events, as you’ve pointed out this situation fails silently, so you need to do a little bit more to debug to confirm this is the case.

One way I discovered to confirm this was this:

After I create a local variable in Blueprint A pointing as an Object Reference to Blueprint B, I can drag from the reference variable like this, and use the “Is Valid” node:

(Make sure to use the “IsValid” node with the Question Mark icon)

If the “Target” variable in this case is NULL, the “Is Not Valid” execution route will happen. I was able to debug variables using this method with print nodes to see that many of my local variables were trying to reference objects that were not created at the time the variables were looking them up, I suppose.

So ultimately, I still haven’t solved the problem, but for now I’m deciding to use some workarounds and will return to this problem in the future when I have a better understanding of Unreal Engine. No use for me to lose my mind over this since I’ve been stuck on this one topic for more than a week.

A couple things I found that could lead folks in the right direction should anyone come across this thread in the future:

  • For these types of issues, consider using the Level Blueprint. Apparently objects placed in the level blueprint are already there when runtime begins, and your references will not fail from what I understand?

https://docs.unrealengine.com/4.27/en-US/ProgrammingAndScripting/Blueprints/UserGuide/Types/Interface/UsingInterfaces/
mentions:

Thanks everyone. For now I’m giving up on this, will be using some workarounds and other methods to achieve my goals. Still a complete beginner so I’m trying not to get too hung up on one thing when there’s a whole world for me to learn. And I’m hoping learning those other topics will in the future make it easier for me to grasp this one once I’m ready.

1 Like