You have to specify a target when calling an interface, and then ensure that target also implements that interface event (in your case, BPI_Chronology).
It seems you are confusing interfaces with global events… this is not how they work.
From what it sounds like, you have to get a reference to your WBP_Interface widget and WBP_Climate widget, and then use those as the target for when you are calling BPI_Chronology in BP_Time.
So generally, what you can do is create a BP of class HUD, a container HUD widget that serves as the container for all individual HUD widget elements (WBP_Interface and WBP_Climate), and then use interfaces to communicate from BP_Time → HUD BP → HUD main widget → WBP_Climate
An example:
HUD class creates and adds the main HUD widget to the viewport
HUD class implements an interface event, with target the created HUD widget from above:
In the HUD widget, the same interface event is implemented, but targets the specific widget (in your case, this would be WBP_Climate for example):
Then in your WBP_Climate, you will just implement the BPI_Chronology interface event and perform your logic as desired.
In your BP_Time, you will either have to get a reference to your HUD class, and then call BPI_Chronology on the hud class. There are many different ways of doing this, but a naive approach would be:
Store the HUD has a reference, and then call BPI_Chronology on it. This will then go through the flow outlined in the above images, and should do what you intend on doing:
Interfaces vs. Casting:
Suppose you are making a shooter game, where if the bullet hits an actor (i.e. BP_Enemy), you want to do some logic on that class.
Now, in the bullet class, when the bullet overlaps with something, you could cast to BP_Enemy, and if true, call a custom “OnHit” function / event you have implemented in BP_Enemy.
The problem with this approach is manifold:
-
This is not scalable… what if you have 1000s of objects that you can hit… and each class has their own bespoke “OnHit” logic? You shouldn’t be branching and casting for every possible instance because in BP_Bullet because:
-
Whenever you cast, you create a dependency / reference from one class to another. This means that for every bullet shot, it needs to async load all the referenced objects in memory.
This becomes a problem on larger projects and lower-end devices where memory is limited
If you’re ever wondering why your editor or game is slow, this is one of the reasons.
What this means in practice is that the bullet will know everything about anything that it can hit, including aspects of the actor that the bullet really doesn’t care much about (i.e. what color the door is that you can shoot, or what sound effect is should play when the bullet shoots the door)
- In principle, the bullet really doesn’t need to know what it has shot, it just needs to know that is has shot something, and whatever was shot, will implement the “OnHit” logic.
Instead, if you implement a single “OnHit” interface everytime the bullet overlaps with something, if the overlapped actor implements the OnHit interface event, it will implement that logic.
This makes your architecture more scalable and modular, and reduces memory footprint.