# c++ Event Nodes

**URL:** <https://forums.unrealengine.com/t/c-event-nodes/89923>\
**Category:** C++\
**Tags:** unreal-engine\
**Created:** [April 14, 2017, 12:03pm UTC](https://forums.unrealengine.com/t/c-event-nodes/89923 "2017-04-14T12:03:06Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_869b0323](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_869b0323](https://forums.unrealengine.com/u/anonymous_user_869b0323)\
**Post date:** [April 14, 2017, 12:03pm UTC](https://forums.unrealengine.com/t/c-event-nodes/89923/1 "2017-04-14T12:03:06Z")

</div>

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:

```auto

	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.

---

<div class="post-metadata">

**Author:** ![ExtraLifeMatt](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/extralifematt/32/918695_2.png) [@ExtraLifeMatt](https://forums.unrealengine.com/u/ExtraLifeMatt)\
**Post date:** [April 14, 2017, 2:54pm UTC](https://forums.unrealengine.com/t/c-event-nodes/89923/2 "2017-04-14T14:54:31Z")

</div>

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](https://wiki.unrealengine.com/Interfaces_in_C%2B%2B) 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:

```auto

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).
}

```

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_869b0323](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_869b0323](https://forums.unrealengine.com/u/anonymous_user_869b0323)\
**Post date:** [April 16, 2017, 10:00am UTC](https://forums.unrealengine.com/t/c-event-nodes/89923/3 "2017-04-16T10:00:04Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![ExtraLifeMatt](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/extralifematt/32/918695_2.png) [@ExtraLifeMatt](https://forums.unrealengine.com/u/ExtraLifeMatt)\
**Post date:** [April 17, 2017, 2:45pm UTC](https://forums.unrealengine.com/t/c-event-nodes/89923/4 "2017-04-17T14:45:01Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![kamrann](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@kamrann](https://forums.unrealengine.com/u/kamrann)\
**Post date:** [April 18, 2017, 4:24am UTC](https://forums.unrealengine.com/t/c-event-nodes/89923/5 "2017-04-18T04:24:17Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_869b0323](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_869b0323](https://forums.unrealengine.com/u/anonymous_user_869b0323)\
**Post date:** [April 18, 2017, 8:21am UTC](https://forums.unrealengine.com/t/c-event-nodes/89923/6 "2017-04-18T08:21:28Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![kamrann](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@kamrann](https://forums.unrealengine.com/u/kamrann)\
**Post date:** [April 18, 2017, 8:39am UTC](https://forums.unrealengine.com/t/c-event-nodes/89923/7 "2017-04-18T08:39:04Z")

</div>

> [@FoxbitRS;696531](#):
>
> 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.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_869b0323](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_869b0323](https://forums.unrealengine.com/u/anonymous_user_869b0323)\
**Post date:** [April 18, 2017, 10:03am UTC](https://forums.unrealengine.com/t/c-event-nodes/89923/8 "2017-04-18T10:03:47Z")

</div>

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)

 ![1.png](https://d3kjluh73b9h9o.cloudfront.net/original/3X/0/6/06eadc3025f86106cf91d6098dd5387b024a66af.png)

but i want:

 ![2.png](https://d3kjluh73b9h9o.cloudfront.net/original/3X/b/e/be633dd16dd559bce543c41c8b188a5851bb95b1.png)

---

<div class="post-metadata">

**Author:** ![kamrann](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@kamrann](https://forums.unrealengine.com/u/kamrann)\
**Post date:** [April 18, 2017, 10:16am UTC](https://forums.unrealengine.com/t/c-event-nodes/89923/9 "2017-04-18T10:16:23Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_869b0323](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_869b0323](https://forums.unrealengine.com/u/anonymous_user_869b0323)\
**Post date:** [April 18, 2017, 10:31am UTC](https://forums.unrealengine.com/t/c-event-nodes/89923/10 "2017-04-18T10:31:13Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ExtraLifeMatt](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/extralifematt/32/918695_2.png) [@ExtraLifeMatt](https://forums.unrealengine.com/u/ExtraLifeMatt)\
**Post date:** [April 18, 2017, 2:06pm UTC](https://forums.unrealengine.com/t/c-event-nodes/89923/11 "2017-04-18T14:06:10Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![BrUnO\_XaVIeR](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/bruno_xavier/32/1110230_2.png) [@BrUnO\_XaVIeR](https://forums.unrealengine.com/u/BrUnO_XaVIeR)\
**Post date:** [April 18, 2017, 3:10pm UTC](https://forums.unrealengine.com/t/c-event-nodes/89923/12 "2017-04-18T15:10:56Z")

</div>

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():

> **[A new, community-hosted Unreal Engine Wiki](https://forums.unrealengine.com/t/a-new-community-hosted-unreal-engine-wiki/141494)**
>
> After over a year in maintenance mode, the official Unreal Engine Wiki is now permanently offline. These resources now live on a new community-run Unreal Engine Community Wiki — ue4community.wiki! You will be able to find content from the official...

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

> **[UFSM: Finite State Machine](https://forums.unrealengine.com/showthread.php?116032-UFSM-Finite-State-Machine&p=695822&viewfull=1#post695822)**
>
> Hello! 🙂 I’ve developed a Plugin module which adds to the UE4 environment a bunch of functionality regarding FSMs, so then I could stop trying to address a bazillion ‘If Then Elses’ everywhere. I haven’t published this yet, but as always, I...

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_869b0323](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_869b0323](https://forums.unrealengine.com/u/anonymous_user_869b0323)\
**Post date:** [April 19, 2017, 2:56pm UTC](https://forums.unrealengine.com/t/c-event-nodes/89923/13 "2017-04-19T14:56:41Z")

</div>

> [@ExtraLifeMatt;696634](#):
>
> 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.

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.
