c++ Event Nodes

Hi,
This is my problem:
I did a new project DLL and imported all functions in UNREAL, all works fine.
I see my nodes( UFUNCTION(BlueprintCallable, Category = “My DLL Library”) ) in blueprints.
My nodes are all STATIC, myclass is a singleton and could be called everyware by nodes actions:



	UFUNCTION(BlueprintCallable, Category = "My DLL Library")
	static void startRecord();


Now i am facing a problem, there is a callback that happen in my C DLL, i send it back to UNREAL and now i dosnt know how to “generate” this event like a “BeginPlay” node.
How could i? I wanna notice other nodes that this happened.

To setup some type of event like that, you need an object of some sort. You can’t just use static method.

You could create a simple interface class, and then setup a registration type system in your singleton which could then ping registered entities when various events happen.

So, pseudo code would look something like this:



static void MyDllLibrary::RegisterListener(UObject* someObject)
{
   check(someObject->IsA<UMyEventInterface>());
   MySingleton::GetSingleton()->RegisterListener(someObject);
}

// In your Singleton class, when an event occurs:

for (UMyEventInterface& Listener : RegisteredListeners)
{
   Listener.MyCustomEvent(); // Where MyCustomEvent is just a method with UFUNCTION(BlueprintNativeEvent, etc).
}


Hi, thanks for your answer.
I actually altredy do what you write, my listener is altredy set and i get the notify in c++ unreal engine code. What is missing now is creation of a “red node” in blueprint for starting propagation in blueprint nodes.
Should i create an interface and implement use in actor component for keep my class and create red nodes?

Ah, sorry for the confusion. In that case I believe you would have to create a custom BP node class and hook it up (find a class that does this and then search the code for that class to see an example), if you wanted to just drop these nodes where ever and not necessarily require a specific character/interface.

The other option is just as you said, create a specific interface that has a BlueprintImplementableEvent for this method and then populate it that way.

The alternative to an interface is to create a dynamic multicast delegate. It’s easier to set up, you just need to embed it as a BlueprintAssignable UPROPERTY on an object that is accessible to Blueprints (so in this case, you could put it on the class itself, then provide a static BlueprintCallable getter method that returns your singleton instance).

The delegate approach requires your listeners to bind at runtime, so it’s not quite as simple to use as just adding an event node like you get with BlueprintImplementableEvent. But the benefit is you don’t put any requirements at all on the class that wants to listen.

Maybe we are doing confusion, i’ll try to be more clear.
I have a singleton class(DLL) with, for example, STOP and START methods.
I implement in c++ unreal engine code “START” and “STOP” nodes, attack STOP to “EndPlay” event and START to “BeginPlay” event in “Level blueprint” scheme. This altredy work.
In my c++ DLL code something start when calling “START”, after a while, fox example a minute, i notify C++ unreal engine code an event, and this works too, now i print “UE_LOG(LogTemp, Warning, TEXT(“test”));” and i see that, so c++ unreal engine code knows about the event.
What is missing is a blueprint node(“Level blueprint” area) that let me start propagation. Something that say(red node static, cause my listener call is static) a minute is pass with some values.

Not entirely sure what you mean by this, but in Blueprint, you can’t create static functions, nor override a method declared as static in C++.

If you only want to respond to this event in your level blueprint, then it’s possible to define your own C++ base class for the level blueprint (never done it, but I think you need to derive from ALevelScriptActor and then specify it somewhere in project settings or config file).
Then you could declare a BlueprintImplementableEvent in that class, call it from your C++ callback, and in the level script blueprint you’d then be able to create the red node and handle it.

Beware though that with level streaming, it’s possible to have multiple level blueprints live simultaneously. So if your DLL only supports having a single listener at a time, you could be overwriting the callback if you called it from level script BeginPlay.

Ok, nevermind i changed my code and now i have what i want. I am able to create a event node, bind event node, call event node.
There is only one last thing, i wanna autobind my component at creation, how could i?
I wanna remove the “bind event” blueprint node and broadcast directly on all.
i have: (i uploaded blueprint with error, bind is connected with begin play)

but i want:

It’s hard to know what you’re actually doing there without seeing the associated code. But the short answer is, you can’t do that with custom events - they are just execution start points, they need to be bound in order to get invoked.

Yea i know they require bound. My question is if i can bound them trought c++ instead of blueprint bind node.
Replace “Bind event to” blueprint node with c++ code.

You want a default binding basically? Or do you want to connect the binding to some random C++ method and have it show up on the Blueprint?

If you created your own Blueprint factory, you could certainly hook up that binding automatically when the blueprint is created - however, it would have to be a method that is already marked as BlueprintPure/BlueprintCallable.

You want to execute an event inside any unknown Blueprint class from your DLL callback;
That means you want to call a Blueprint Interface function from the callback; you won’t be able to auto bind C++ delegates like that, also the Blueprint user must implement the interface and drop the “red node” event function from the interface to be able to use it.

Calling Blueprint implemented Interfaces from C++ is a little tricky, here I’ve added some example;
In last example code, the “red node” event is fired from C++ BeginPlay():

There’s some more datails about the Blueprint side of things here:

I have some events in actor component(i changed the way i was at begin), i wanna notice them in blueprint without the user create “bind to” nodes, like it’s altredy done by c++ code.