# Expand Node : generate and call an event

**URL:** <https://forums.unrealengine.com/t/expand-node-generate-and-call-an-event/438936>\
**Category:** Blueprint\
**Tags:** custom-event, compilation-error, unreal-engine, custom-nodes, Blueprint, CPP, question\
**Created:** [December 5, 2018, 9:02pm UTC](https://forums.unrealengine.com/t/expand-node-generate-and-call-an-event/438936 "2018-12-05T21:02:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![CraftyWeazel](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@CraftyWeazel](https://forums.unrealengine.com/u/CraftyWeazel)\
**Post date:** [December 5, 2018, 9:02pm UTC](https://forums.unrealengine.com/t/expand-node-generate-and-call-an-event/438936/1 "2018-12-05T21:02:52Z")

</div>

Hi there!

I’m currently struggling to achieve something with custom K2 nodes. I prefer not to explain why (it would be _very_ long), but I would like to make a node that can expand like shown in the image below, when ExpandNode(…) is called at the expansion step of blueprint compilation.

The idea is to _cut_ the execution flow and generate a custom event + a call to that event.  
I know it sound very stupid presented like that, but actually this is just an example I made to ask my question. If someone can answer me, I will use that answer for a completely different thing. Quickly, it’s about an almost-pure node that would create an event and generate an object with a reference to this event to be fired later.

I know a bit the blueprint compilation process, but I’m still struggling to get my way with Delegates, FMemberReference(s) and UFunction(s)… Anyone has an idea on how to do it ?

 ![261388-ue4-node-expand.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/9/f/59f01b14caadcf782100acc3604c7cbea21e0f21.png)

I tried that, but it’s not working at all. It’s saying that a function called “DialogEvent\_0” wasn’t found, as a compilation error log.

```
UK2Node_CustomEvent* EventNode = CompilerContext.SpawnIntermediateEventNode<UK2Node_CustomEvent>(this);
EventNode->CustomFunctionName = "DialogEvent";
EventNode->RenameCustomEventCloseToName();
EventNode->AllocateDefaultPins();
EventNode->GetPinAt(1)->MakeLinkTo(GetThenPin()->LinkedTo[0]);
GetThenPin()->BreakAllPinLinks();

UK2Node_CallFunction* FireEventNode = CompilerContext.SpawnIntermediateNode<UK2Node_CallFunction>(this);
FireEventNode->SetFromFunction(EventNode->FindEventSignatureFunction());
FireEventNode->AllocateDefaultPins();
GetThenPin()->MakeLinkTo(FireEventNode->GetExecPin());
```

---

<div class="post-metadata">

**Author:** ![CraftyWeazel](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@CraftyWeazel](https://forums.unrealengine.com/u/CraftyWeazel)\
**Post date:** [December 13, 2018, 11:26pm UTC](https://forums.unrealengine.com/t/expand-node-generate-and-call-an-event/438936/2 "2018-12-13T23:26:56Z")

</div>

I managed to do it and answered with an explanation in this other thread I made :

> **[Store a reference to a BP event in C++ and call it](https://forums.unrealengine.com/questions/855025/view.html)**
>
> Hi there! I would like advice from programmers on UE4 about this question: from a custom blueprint node that expands in a UK2Node\_CallFunction, how can I send to a C++ function the reference of an event created in blueprints? Then, with that...
