# Custom K2 Nodes with Delegates

**URL:** <https://forums.unrealengine.com/t/custom-k2-nodes-with-delegates/457550>\
**Category:** Blueprint\
**Tags:** unreal-engine, delegates, CPP, Blueprint, question\
**Created:** [October 26, 2019, 2:13am UTC](https://forums.unrealengine.com/t/custom-k2-nodes-with-delegates/457550 "2019-10-26T02:13:37Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![MagForceSeven](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/magforceseven/32/906563_2.png) [@MagForceSeven](https://forums.unrealengine.com/u/MagForceSeven)\
**Post date:** [October 26, 2019, 2:13am UTC](https://forums.unrealengine.com/t/custom-k2-nodes-with-delegates/457550/1 "2019-10-26T02:13:37Z")

</div>

I’m trying to figure out how to integrate my systems into blueprint. In native I have a custom event dispatching that leverages templates nicely to register to receive events of a certain type. I would like to be able to do this from blueprint directly as well instead of requiring boilerplate native that does event registration that routes to a blueprint.

This is what I have so far, a custom K2 node ‘Register for Event’. The primary inputs are the class type that represents the event type to be notified for and the delegate to call when that event happens.

 ![291130-delegate.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/4/e/84e20000e2e87860adf9037073c8c3957e76b7fa.png)

What I would like to figure out is a way to update the delegate signature “B” based on changes to the event type “A”. The problem that I’ve ran into is in the configuration of delegate pins involve the referencing of a UFunction. Since the one of the points of the system is that the event system doesn’t know the concrete event types involved, I would prefer not to have to specify a bunch of unused functions.

I wouldn’t mind as much generating a bunch of unused delegate declarations (using the DECLARE\_DELEGATE macros) however I was unable to determine how to get a UFunction reference from that as needed to configure a pin of type PC\_Delegate.

I’m looking for any direction that may help. I’m open to alternative suggestions that would get me to my goal provided they meet the functionality requirements I’m trying to reach.

---

<div class="post-metadata">

**Author:** ![FourRoadTitans](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/fourroadtitans/32/572794_2.png) [@FourRoadTitans](https://forums.unrealengine.com/u/FourRoadTitans)\
**Post date:** [October 30, 2023, 2:00am UTC](https://forums.unrealengine.com/t/custom-k2-nodes-with-delegates/457550/2 "2023-10-30T02:00:56Z")

</div>

Hi! Did you have found any ideas?

---

<div class="post-metadata">

**Author:** ![DTG\_DaveW](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@DTG\_DaveW](https://forums.unrealengine.com/u/DTG_DaveW)\
**Post date:** [May 14, 2024, 4:51pm UTC](https://forums.unrealengine.com/t/custom-k2-nodes-with-delegates/457550/3 "2024-05-14T16:51:11Z")

</div>

If you can get an FMulticastDelegateProperty or FDelegateProperty from wherever you’re getting your list of event types, which I assume is a UClass of some kind, you can then get the SignatureFunction from that.

---

<div class="post-metadata">

**Author:** ![Auran131](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Auran131](https://forums.unrealengine.com/u/Auran131)\
**Post date:** [October 18, 2024, 2:06pm UTC](https://forums.unrealengine.com/t/custom-k2-nodes-with-delegates/457550/4 "2024-10-18T14:06:15Z")

</div>

how did you create the input event @MagForceSeven ?

i tried with code below which created the pin but when connected said it was the wrong direction. Also how did you add the signature? im still stumbling through the dark with K2Nodes ☹

if (UEdGraphPin\* DelegatePin = CreatePin(EGPD\_Input, UEdGraphSchema\_K2::PC\_Delegate, Property-\>GetFName()))  
{  
K2Schema-\>ConstructBasicPinTooltip(\*DelegatePin, Property-\>GetToolTipText(), DelegatePin-\>PinToolTip);

```
			}

```

---

<div class="post-metadata">

**Author:** ![MagForceSeven](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/magforceseven/32/906563_2.png) [@MagForceSeven](https://forums.unrealengine.com/u/MagForceSeven)\
**Post date:** [October 18, 2024, 3:06pm UTC](https://forums.unrealengine.com/t/custom-k2-nodes-with-delegates/457550/5 "2024-10-18T15:06:26Z")

</div>

Per the comment on PC\_Delegate, you set the SubCategoryObject to a UFunction pointer.

> [@DTG\_DaveW](#):
>
> … you can then get the SignatureFunction from that

@DTG_DaveW No you can’t. That would require every class to manually declare a bunch of functions or delegate properties to create the variations with that specific class type. Which is just pointless boilerplate. Ultimately I wrote this as a custom node that combined the two nodes from the original post into a single node with a drop down so that I could do the type validation instead of relying on the delegate pin.

---

<div class="post-metadata">

**Author:** ![Auran131](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Auran131](https://forums.unrealengine.com/u/Auran131)\
**Post date:** [October 19, 2024, 5:50am UTC](https://forums.unrealengine.com/t/custom-k2-nodes-with-delegates/457550/6 "2024-10-19T05:50:04Z")

</div>

thanks but can i have no idea how 😅

i cant find any code on this stuff if you could show me or point me in the right direction.

---

<div class="post-metadata">

**Author:** ![MagForceSeven](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/magforceseven/32/906563_2.png) [@MagForceSeven](https://forums.unrealengine.com/u/MagForceSeven)\
**Post date:** [October 19, 2024, 1:53pm UTC](https://forums.unrealengine.com/t/custom-k2-nodes-with-delegates/457550/7 "2024-10-19T13:53:42Z")

</div>

Generally, you would use a UClass\* to the class with the function you want and you’d call `FindFunction` or `FindFunctionChecked`. You can also call the same functions on any UObject\* add it will delegate to whatever class the UObject instance is.

---

<div class="post-metadata">

**Author:** ![Auran131](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Auran131](https://forums.unrealengine.com/u/Auran131)\
**Post date:** [October 20, 2024, 7:37am UTC](https://forums.unrealengine.com/t/custom-k2-nodes-with-delegates/457550/8 "2024-10-20T07:37:37Z")

</div>

ive created OutDelegates fine but i don’t think you can add a Signature to those, so i want the option to switch it to an InDelegate but when i connect it to an event it says pin is wrong direction or something.

will try post a screenshot soon
