{"id":1102,"date":"2022-06-26T15:40:10","date_gmt":"2022-06-26T06:40:10","guid":{"rendered":"https:\/\/colory-games.net\/site\/?p=1102"},"modified":"2023-11-04T20:48:28","modified_gmt":"2023-11-04T11:48:28","slug":"create-your-own-blueprint-node-by-inheriting-k2node-2-execution-pin-en","status":"publish","type":"post","link":"https:\/\/colory-games.net\/site\/en\/create-your-own-blueprint-node-by-inheriting-k2node-2-execution-pin-en\/","title":{"rendered":"[UE5] Create Your Own Blueprint Node by Inheriting K2Node (2) Execution Pin"},"content":{"rendered":"\n<div class=\"wp-block-jetpack-markdown\"><p>This article explains how to create a blueprint node with an execution pin.<br>\nThe explanation assumes that you are familiar with the basic contents of creating the Blueprint node.<br>\nPlease check <a href=\"https:\/\/colory-games.net\/site\/en\/create-your-own-blueprint-node-by-inheriting-k2node-1-basic-en\/\">the Basic article<\/a> if necessary.<\/p>\n<ul>\n<li><a href=\"https:\/\/colory-games.net\/site\/en\/create-your-own-blueprint-node-by-inheriting-k2node-1-basic-en\/\">Create Your Own Blueprint Node by Inheriting K2Node (1) Basic<\/a><\/li>\n<li>Create Your Own Blueprint Node by Inheriting K2Node (2) Execution Pin &lt;&#8212; This article<\/li>\n<li><a href=\"https:\/\/colory-games.net\/site\/en\/create-your-own-blueprint-node-by-inheriting-k2node-3-menu-en\/\">Create Your Own Blueprint Node by Inheriting K2Node (3) Menu<\/a><\/li>\n<li><a href=\"https:\/\/colory-games.net\/site\/en\/create-your-own-blueprint-node-by-inheriting-k2node-4-ui-en\/\">Create Your Own Blueprint Node by Inheriting K2Node (4) UI<\/a><\/li>\n<\/ul>\n<div id=\"toc_container\" class=\"no_bullets\"><p class=\"toc_title\">\u76ee\u6b21<\/p><ul class=\"toc_list\"><li><a href=\"#Source_Code\">Source Code<\/a><\/li><li><a href=\"#Specification_of_the_Blueprint_Node\">Specification of the Blueprint Node<\/a><\/li><li><a href=\"#Create_a_Module\">Create a Module<\/a><\/li><li><a href=\"#Create_a_Blueprint_Node\">Create a Blueprint Node<\/a><ul><li><a href=\"#3_Add_Pins\">3. Add Pins<\/a><\/li><li><a href=\"#4_Add_Internal_Pins\">4. Add Internal Pins<\/a><\/li><li><a href=\"#5_Define_the_Process_of_Execution_Pins\">5. Define the Process of Execution Pins<\/a><\/li><\/ul><\/li><li><a href=\"#Use_the_Created_Node\">Use the Created Node<\/a><\/li><li><a href=\"#References\">References<\/a><\/li><\/ul><\/div>\n<h1><span id=\"Source_Code\">Source Code<\/span><\/h1>\n<p>The complete source code is available on GitHub.<\/p>\n<p><a href=\"https:\/\/github.com\/colory-games\/techblog-sample-projects\/tree\/main\/nutti\/20220626\">https:\/\/github.com\/colory-games\/techblog-sample-projects\/tree\/main\/nutti\/20220626<\/a><\/p>\n<p>To run the source code, follow these steps.<\/p>\n<ol>\n<li>Place the directory <code>MyCompareInt<\/code> into <code>Plugins<\/code> in your Unreal Engine project directory.<\/li>\n<li>Right click on the <code>.uproject<\/code> file and create a project file for Visual Studio.<\/li>\n<li>Open the project file and build the project.<\/li>\n<li>Run Unreal Engine from the <code>.uproject<\/code> file and activate the &quot;MyCompareInt&quot; plugin.<\/li>\n<\/ol>\n<h1><span id=\"Specification_of_the_Blueprint_Node\">Specification of the Blueprint Node<\/span><\/h1>\n<p>The specification of the Blueprint node &quot;MyCompareInt&quot; is as follows.<\/p>\n<ul>\n<li>Receives two integers &quot;A&quot; and &quot;B&quot; as inputs.<\/li>\n<li>Changes the output execution pin to be executed depending on the inputs &quot;A&quot; and &quot;B&quot;.\n<ul>\n<li>Execution pin &quot;Greater&quot;: Execute when A&gt;B<\/li>\n<li>Execution pin &quot;Equal&quot;: Execute when A=B<\/li>\n<li>Execution pin &quot;Less&quot;: Execute when A&lt;B<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>This specification is similar to the macro &quot;Compare Int&quot; provided in the Blueprint.<br>\nPlease check the implementation of the macro &quot;Compare Int&quot; if necessary.<\/p>\n<h1><span id=\"Create_a_Module\">Create a Module<\/span><\/h1>\n<p>Create a module by following to the description in the Basic section.<br>\nFor the concreate instructions to create a module, please refer to the <a href=\"https:\/\/colory-games.net\/site\/en\/create-your-own-blueprint-node-by-inheriting-k2node-1-basic-en\/\">article for the basic<\/a>.<\/p>\n<h1><span id=\"Create_a_Blueprint_Node\">Create a Blueprint Node<\/span><\/h1>\n<p>We can create a Blueprint node by the following steps.<\/p>\n<ol>\n<li>Inherit class <code>UK2Node<\/code>.<\/li>\n<li>Setup basic information.<\/li>\n<li>Add pins.<\/li>\n<li>Add internal pins.<\/li>\n<li>Define the process of execution pins.<\/li>\n<\/ol>\n<p>Steps 1 and 2 are the almost same as in the <a href=\"https:\/\/colory-games.net\/site\/en\/create-your-own-blueprint-node-by-inheriting-k2node-1-basic-en\/\">article for the basic<\/a>, so we will start from step 3.<\/p>\n<h2><span id=\"3_Add_Pins\">3. Add Pins<\/span><\/h2>\n<p>Add the following pins according to the specification.<\/p>\n<table>\n<thead>\n<tr>\n<th><strong>Pin Name<\/strong><\/th>\n<th><strong>Input\/Output<\/strong><\/th>\n<th><strong>Role<\/strong><\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><\/td>\n<td>Input<\/td>\n<td>Execute the node.<\/td>\n<\/tr>\n<tr>\n<td>A<\/td>\n<td>Input<\/td>\n<td>Input of integer.<\/td>\n<\/tr>\n<tr>\n<td>B<\/td>\n<td>Input<\/td>\n<td>Input of integer.<\/td>\n<\/tr>\n<tr>\n<td>Greater<\/td>\n<td>Output<\/td>\n<td>Execute when A&gt;B<\/td>\n<\/tr>\n<tr>\n<td>Equal<\/td>\n<td>Output<\/td>\n<td>Execute when A=B<\/td>\n<\/tr>\n<tr>\n<td>Less<\/td>\n<td>Output<\/td>\n<td>Execute when A&lt;B<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>We need to add those pins.<br>\n<code>AllocateDefaultPins<\/code> is the member funciton which defines the process of adding pins to the node.<\/p>\n<pre><code class=\"language-cpp\">CreatePin(EGPD_Input, UEdGraphSchema_K2::PC_Exec, UEdGraphSchema_K2::PN_Execute);\nCreatePin(EGPD_Input, UEdGraphSchema_K2::PC_Int, APinName);\nCreatePin(EGPD_Input, UEdGraphSchema_K2::PC_Int, BPinName);\nCreatePin(EGPD_Output, UEdGraphSchema_K2::PC_Exec, GreaterPinName);\nCreatePin(EGPD_Output, UEdGraphSchema_K2::PC_Exec, EqualPinName);\nCreatePin(EGPD_Output, UEdGraphSchema_K2::PC_Exec, LessPinName);\n<\/code><\/pre>\n<p>To add an execution pin, specify <code>UEdGraphSchema_K2::PC_Exec<\/code> for the second argument.<br>\nIf you want to add execution pin on the input side that triggers node execution, the third argument needs to be <code>UEdGraphSchema_K2::PN_Execute<\/code>.<\/p>\n<p>Add three execution pins on the output side as well.<br>\nWe add execution pins whose names are Greater, Equal, and Less.<\/p>\n<h2><span id=\"4_Add_Internal_Pins\">4. Add Internal Pins<\/span><\/h2>\n<p>The node &quot;MyCompareInt&quot; needs to determine the pin on the output side to be executed according to the value of the input integers &quot;A&quot; and &quot;B&quot;.<\/p>\n<ul>\n<li>When &quot;A&gt;B&quot;, execute the pin &quot;Greater&quot;.<\/li>\n<li>When &quot;A=B&quot;, execute the pin &quot;Equal&quot;.<\/li>\n<li>When &quot;A&lt;B&quot;, execute the pin &quot;Less&quot;.<\/li>\n<\/ul>\n<p>We can implement this in Blueprint as follows.<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/colory-games.net\/site\/wp-content\/uploads\/tech-blog\/nutti\/2022\/06\/20220626\/blueprint_implementation_1.png?ssl=1\"><img decoding=\"async\" src=\"https:\/\/i0.wp.com\/colory-games.net\/site\/wp-content\/uploads\/tech-blog\/nutti\/2022\/06\/20220626\/blueprint_implementation_1.png?ssl=1\" alt=\"Implementation in Blueprint 1\" data-recalc-dims=\"1\"><\/a><\/p>\n<p>However, we will implement as follows.<\/p>\n<ol>\n<li>Pass the inputs &#8216;A&#8217; and &#8216;B&#8217; to the library function <code>UKismetMathLibrary::GreaterEqual_IntInt<\/code>. If the result is <code>False<\/code>, execute the node connected to the execution pin &#8216;Less&#8217;.<\/li>\n<li>If the result of 1 is <code>True<\/code>, pass the inputs &#8216;A&#8217; and &#8216;B&#8217; to the library function <code>UKismetMathLibrary::LessEqual_IntInt<\/code>. If the result is <code>False<\/code>, execute the node connected to the execution pin &#8216;Greater&#8217;.<\/li>\n<li>If the result of 2 is <code>True<\/code>, execute the node connected to the execution pin <code>Equal<\/code>.<\/li>\n<\/ol>\n<p>To realize in Blueprint, you can implement this as follows.<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/colory-games.net\/site\/wp-content\/uploads\/tech-blog\/nutti\/2022\/06\/20220626\/blueprint_implementation_2.png?ssl=1\"><img decoding=\"async\" src=\"https:\/\/i0.wp.com\/colory-games.net\/site\/wp-content\/uploads\/tech-blog\/nutti\/2022\/06\/20220626\/blueprint_implementation_2.png?ssl=1\" alt=\"Implementation in Blueprint 2\" data-recalc-dims=\"1\"><\/a><\/p>\n<p>To achieve, you need to understand the following two things.<\/p>\n<ul>\n<li>Add an internal pin, which is required to call the library function.<\/li>\n<li>Determine the execution pin to execute by using the output result of the added library function.<\/li>\n<\/ul>\n<p>First, we will desribe the process of adding the internal pins required for a library function call.<br>\nUse the member function <code>CreatePin<\/code> is used to add the internal pins.<\/p>\n<pre><code class=\"language-cpp\">UEdGraphPin* FunctionPin = CreatePin(EGPD_Input, UEdGraphSchema_K2::PC_Object, UKismetMathLibrary::StaticClass(), TEXT(&quot;GreaterEqual_IntInt&quot;));\nFunctionPin->bDefaultValueIsReadOnly = true;\nFunctionPin->bNotConnectable = true;\nFunctionPin->bHidden = true;\n<\/code><\/pre>\n<p>We specify the second argument of the <code>UEdGraphSchema_K2::PC_Object<\/code>.<br>\nWe specify the blueprint library function to the third argument, and specify the name of the library function to the fourth argument.<\/p>\n<p>Use the return value of the library function <code>CreatePin<\/code> and apply various configuration to make the internal pin read-only.<br>\nThe pin to execute the library function has been created, but there is no library function to execute.<\/p>\n<p>The process for setting the library function is shown below.<\/p>\n<pre><code class=\"language-cpp\">UFunction* Function = FindUField(UKismetMathLibrary::StaticClass(), TEXT(&quot;GreaterEqual_IntInt&quot;));\nif (Function != nullptr &amp;&amp; Function->HasAllFunctionFlags(FUNC_Static))\n{\n    UBlueprint* Blueprint = GetBlueprint();\n    if (Blueprint != nullptr)\n    {\n        UClass* FunctionOwnerClass = Function->GetOuterUClass();\n        if (!Blueprint->SkeletonGeneratedClass->IsChildOf(FunctionOwnerClass))\n        {\n            FunctionPin->DefaultObject = FunctionOwnerClass->GetDefaultObject();\n        }\n    }\n}\n<\/code><\/pre>\n<p>Call the function <code>FindUField<\/code> to get the <code>UFunction<\/code> of the library function <code>UKismetMathLibrary::GreaterEqual_IntInt<\/code>.<br>\nThen, set <code>UFunction<\/code> to the member variable <code>DefaultObject<\/code> of the created inner pin <code>FunctionPin<\/code>.<br>\nThis allows the inner pin to execute the library function <code>UKismetMathLibrary::GreaterEqual_IntInt<\/code>.<\/p>\n<p>In the same way, you can create an inner pin to execute the library function <code>UKismetMathLibrary::LessEqual_IntInt<\/code>.<\/p>\n<h2><span id=\"5_Define_the_Process_of_Execution_Pins\">5. Define the Process of Execution Pins<\/span><\/h2>\n<p>We will implement a process that uses the output result of a library function to determine the execution pin to be executed.<br>\nWe defined a computation graph by using the member function <code>ExpandNode<\/code>.<br>\nHowever, the member function <code>ExpandNode<\/code> cannot realize the process of selecting a pin to execute based on a specific condition.<br>\nTo realize this, you need to define a class <code>FKCHandler_MyCompareInt<\/code> inherited from class <code>FNodeHandlingFunctor<\/code>.<\/p>\n<pre><code class=\"language-cpp\">class FKCHandler_MyCompareInt : public FNodeHandlingFunctor\n{\n    TMap BoolTermMap;\npublic:\n    FKCHandler_MyCompareInt(FKismetCompilerContext&amp; InCompilerContext) : FNodeHandlingFunctor(InCompilerContext)\n    {\n    }\n    virtual void RegisterNets(FKismetFunctionContext&amp; Context, UEdGraphNode* Node) override\n    {\n        \/\/ snip\n    }\n    virtual void Compile(FKismetFunctionContext&amp; Context, UEdGraphNode* Node) override\n    {\n        \/\/ snip\n    }\n};\n<\/code><\/pre>\n<h3>Create Variables<\/h3>\n<p>The member function <code>RegisterNets<\/code> defines the process of creating temporary variables to store the results of the library functions you have executed.<br>\nThe temporary variables will be used later.<\/p>\n<pre><code class=\"language-cpp\">virtual void RegisterNets(FKismetFunctionContext&amp; Context, UEdGraphNode* Node) override\n{\n    FNodeHandlingFunctor::RegisterNets(Context, Node);\n    {\n        \/\/ Store the result of library function &quot;UKismetMathLibrary::GreaterEqual_IntInt&quot;\n        \/\/ to the temporary boolean variable.\n        FBPTerminal* BoolTerm = Context.CreateLocalTerminal();\n        BoolTerm->Type.PinCategory = UEdGraphSchema_K2::PC_Boolean;\n        BoolTerm->Source = Node;\n        BoolTerm->Name = Context.NetNameMap->MakeValidName(Node, TEXT(&quot;IsGreaterEqual&quot;));\n        BoolTermMap.Add(TEXT(&quot;IsGreaterEqual&quot;), BoolTerm);\n    }\n}\n<\/code><\/pre>\n<p>The member function <code>RegisterNets<\/code> must first call <code>RegisterNets<\/code> of the parent class.<br>\nAfter calling <code>RegisterNets<\/code> of the parent class, create a boolean variable by calling the member function <code>CreateLocalTerminal<\/code> with the argument <code>Context<\/code>.<br>\nWe repeat this process twice, to create the variables <code>IsGreaterEqual<\/code> and <code> IsLessEqual<\/code> for storing the results of <code>UKismetMathLibrary::LessEqual_IntInt<\/code>.<\/p>\n<p>The created variables are registered in the member variable <code>BoolTermMap<\/code> to be used while the Blueprint compilation.<\/p>\n<h3>Blueprint Compilation<\/h3>\n<p>The member function <code>Compile<\/code> defines the process to be called while the Blueprint compilation.<br>\nThis function will add a Blueprint statement <code>FKismetCompiledStatement<\/code>.<\/p>\n<p>The member function <code>Compile<\/code> defined here can be called in the <a href=\"https:\/\/docs.unrealengine.com\/5.0\/en-US\/compiler-overview-for-blueprints-visual-scripting-in-unreal-engine\/#compilefunctions\">Compile Functions<\/a> phase.\nThe concreate process of Blueprint compilation is described in the official documentation <a href=\"https:\/\/docs.unrealengine.com\/5.0\/en-US\/compiler-overview-for-blueprints-visual-scripting-in-unreal-engine\/\">Blueprint Compiler Overview<\/a>.<\/p>\n<p>The Blueprint statement type can be found in the  <a href=\"https:\/\/docs.unrealengine.com\/5.0\/en-US\/API\/Editor\/KismetCompiler\/EKismetCompiledStatementType\/\">EKismetCompiledStatementType<\/a>.<br>\nWe will use the following statement types.<\/p>\n<table>\n<thead>\n<tr>\n<th><strong>Statement Type<\/strong><\/th>\n<th><strong>Meaning<\/strong><\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>KCST_CallFunction<\/code><\/td>\n<td>Calls a function (<code>UFunction<\/code>)<\/td>\n<\/tr>\n<tr>\n<td><code>KCST_GotoIfNot<\/code><\/td>\n<td>Transfer the control of execution to a specific execution pin if the specified condition is <code>False<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>KCST_UnconditionalGoto<\/code><\/td>\n<td>Unconditionally transfer the control of execution to a specific execution pin<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>A statement can be created by calling the member function <code>AppendStatementForNode<\/code> with the argument <code>Context<\/code>.<br>\nThe return value is the structure <code>FBlueprintCompiledStatement<\/code>.<br>\nThe member variable <code>Type<\/code> is a statement type, and <code>LHS<\/code> and <code>RHS<\/code> are variables to be passed to the statement.<br>\nThe meaning of the variables depends on the statement type, see <a href=\"https:\/\/docs.unrealengine.com\/5.0\/en-US\/API\/Editor\/KismetCompiler\/EKismetCompiledStatementType\/\">EKismetCompiledStatementType<\/a> for detail.<\/p>\n<h4>Get Required Variables for the Compilation<\/h4>\n<p>The member function <code>Compile<\/code> first retrieves variables needed at compilation time.<\/p>\n<pre><code class=\"language-cpp\">virtual void Compile(FKismetFunctionContext&amp; Context, UEdGraphNode* Node) override\n{\n    UK2Node_MyCompareInt* MyCompareIntNode = CastChecked(Node);\n    \/\/ Get execution pin on the output side.\n    UEdGraphPin* GreaterPin = MyCompareIntNode->FindPin(GreaterPinName);\n    UEdGraphPin* EqualPin = MyCompareIntNode->FindPin(EqualPinName);\n    UEdGraphPin* LessPin = MyCompareIntNode->FindPin(LessPinName);\n    \/\/ Get temporary variables.\n    FBPTerminal* IsGreaterEqualTerm = BoolTermMap.FindRef(TEXT(&quot;IsGreaterEqual&quot;));\n    FBPTerminal* IsLessEqualTerm = BoolTermMap.FindRef(TEXT(&quot;IsLessEqual&quot;));\n    \/\/ Get variables of input pin &quot;A&quot;.\n    UEdGraphPin* APin = MyCompareIntNode->FindPin(APinName);\n    UEdGraphPin* ANet = FEdGraphUtilities::GetNetFromPin(APin);\n    FBPTerminal* ATerm = Context.NetMap.FindRef(ANet);\n    \/\/ Get variables of input pin &quot;B&quot;.\n    UEdGraphPin* BPin = MyCompareIntNode->FindPin(BPinName);\n    UEdGraphPin* BNet = FEdGraphUtilities::GetNetFromPin(BPin);\n    FBPTerminal* BTerm = Context.NetMap.FindRef(BNet);\n}\n<\/code><\/pre>\n<p><code>FBPTerminal<\/code> is the equivalent of a variable in the statement.<br>\nNote that class <code>UEdGraphPin<\/code> does not represent the execution pin.<br>\nWe will get the following variables.<\/p>\n<table>\n<thead>\n<tr>\n<th><strong>Variable Name<\/strong><\/th>\n<th><strong>Meaning<\/strong><\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>IsGreaterEqualTerm<\/code><\/td>\n<td>Store the result of the library function <code>UKismetMathLibrary::GreaterEqual_IntInt<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>IsLessEqualTerm<\/code><\/td>\n<td>Store the result of library function <code>UKismetMathLibrary::LessEqual_IntInt<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>ATerm<\/code><\/td>\n<td>Input pin &quot;A&quot;<\/td>\n<\/tr>\n<tr>\n<td><code>BTerm<\/code><\/td>\n<td>input pin &quot;B&quot;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>Create Blueprint Statement<\/h4>\n<p>We will create Blueprint statements.<br>\nAs we mentioned earlier, there is no statement type that transfers execution control to a specific execution pin if the specified condition is <code>True<\/code>.<br>\nIn step 4, we changed the method of implementation to take into account this constraint.<\/p>\n<ol>\n<li>Pass the inputs &quot;A&quot; and &quot;B&quot; to the library function <code>UKismetMathLibrary::GreaterEqual_IntInt<\/code>. If the result is <code>False<\/code>, execute the node connected to the execution pin &quot;Less&quot;.<\/li>\n<li>If the result of 1 is <code>True<\/code>, pass the inputs &quot;A&quot; and &quot;B&quot; to the library function <code>UKismetMathLibrary::LessEqual_IntInt<\/code>. If the result is <code>False<\/code>, execute the node connected to the execution pin &quot;Greater&quot;.<\/li>\n<li>If the result of 2 is <code>True<\/code>, execute the node connected to the execution pin &quot;Equal&quot;.<\/li>\n<\/ol>\n<p>We will show the pseudo code for a C++ implementation.<\/p>\n<pre><code class=\"language-cpp\">IsGreaterEqualTerm = UKismetMathLibrary::GreaterEqual_IntInt(ATerm, BTerm);\nif (!IsGreaterEqualTerm) {\n    goto LessPin;\n}\nIsLessEqualTerm = UKismetMathLibrary::LessEqual_IntInt(ATerm, BTerm);\nif (!IsLessEqualTerm) {\n    goto GreaterPin;\n}\ngoto EqualPin;\n<\/code><\/pre>\n<p>This can be rewritten into a blueprint statement as follows.<\/p>\n<pre><code>KCST_CallFunction IsGreaterEqualTerm [ATerm, BTerm]\nKCST_GotoIfNot IsGreaterEqualTerm -> LessPin\nKCST_CallFunction IsLessEqualTerm [ATerm, BTerm]\nKCST_GotoIfNot IsLessEqualTerm -> GreaterPin\nKCST_UnconditionalGoto -> EqualPin\n<\/code><\/pre>\n<p>We will create these statements in the member function <code>Compile<\/code>.<\/p>\n<pre><code class=\"language-cpp\">virtual void Compile(FKismetFunctionContext&amp; Context, UEdGraphNode* Node) override\n{\n    \/\/ snip\n    {\n        \/\/ Get UFunction of the library function &quot;UKismetMathLibrary::GreaterEqual_IntInt&quot;.\n        UEdGraphPin* FunctionPin = MyCompareIntNode->FindPin(TEXT(&quot;GreaterEqual_IntInt&quot;));\n        FBPTerminal* FunctionContext = Context.NetMap.FindRef(FunctionPin);\n        UClass* FunctionClass = Cast(FunctionPin->PinType.PinSubCategoryObject.Get());\n        UFunction* FunctionPtr = FindUField(FunctionClass, FunctionPin->PinName);\n        \/\/ Create a statement that calls a library function.\n        FBlueprintCompiledStatement&amp; CallFuncStatement = Context.AppendStatementForNode(MyCompareIntNode);\n        CallFuncStatement.Type = KCST_CallFunction;\n        CallFuncStatement.FunctionToCall = FunctionPtr;\n        CallFuncStatement.FunctionContext = FunctionContext;\n        CallFuncStatement.bIsParentContext = false;\n        CallFuncStatement.LHS = IsGreaterEqualTerm;\n        CallFuncStatement.RHS.Add(ATerm);\n        CallFuncStatement.RHS.Add(BTerm);\n        \/\/ Create a statement that transfers execution control to the execution pin &quot;LessPin&quot; when the result of a library function call is false.\n        FBlueprintCompiledStatement&amp; GotoStatement = Context.AppendStatementForNode(MyCompareIntNode);\n        GotoStatement.Type = KCST_GotoIfNot;\n        GotoStatement.LHS = IsGreaterEqualTerm;\n        Context.GotoFixupRequestMap.Add(&amp;GotoStatement, LessPin);\n    }\n    {\n        \/\/ snip\n        \/\/ Create a statement that transfers execution control to the execution pin &quot;GreaterPin&quot; when the result of a library function call is false.\n        FBlueprintCompiledStatement&amp; GotoStatement = Context.AppendStatementForNode(MyCompareIntNode);\n        GotoStatement.Type = KCST_GotoIfNot;\n        GotoStatement.LHS = IsLessEqualTerm;\n        Context.GotoFixupRequestMap.Add(&amp;GotoStatement, GreaterPin);\n    }\n    \/\/ If none of the conditions are met, create a statement that unconditionally transfers execution control to the execution pin &quot;EqualPin&quot;.\n    GenerateSimpleThenGoto(Context, *MyCompareIntNode, EqualPin);\n}\n<\/code><\/pre>\n<p>First, get the <code>UFunction<\/code> of the library function <code>UKismetMathLibrary::GreaterEqual_IntInt<\/code> to be used for creating Blueprint statements.<br>\nIt can be obtained from the internal pin created in step 4.<\/p>\n<p>Next, call the member function <code>AppendStatementForNode<\/code> of <code>Context<\/code> to create a statement <code>KCST_CallFunction<\/code> that calls the library function.<br>\nSet the member variable <code>Type<\/code> of the structure <code>FBlueprintCompiledStatement<\/code> to <code>KCST_CallFunction<\/code>.<br>\nThis indicates that this statement calls a library function.<br>\nThe member variable <code>FunctionToCall<\/code> is set to the <code>UFunction<\/code> of the library function to be called in this statement.<br>\nSet the member variable <code>LHS<\/code> to the variable <code>IsGreaterEqualTerm<\/code> that stores the return value of the library function.<br>\nSet the member variable <code>RHS<\/code> to the values to be passed as the argument of the library function in the correct order.<br>\nIn this case, <code>ATerm<\/code> and <code>BTerm<\/code> are arguments.<\/p>\n<p>Then, we will create the statement <code>KCST_GotoIfNot<\/code>, which transfers execution control to a specific execution pin if the specified condition is <code>False<\/code>.<br>\nSpecify <code>IsGreaterEqualTerm<\/code> to the member variable <code>LHS<\/code> so that execution control is transferred when <code>IsGreaterEqualTerm<\/code> is <code>False<\/code> (&quot;A&lt;B&quot;).<br>\nSince the destination of the execution control is the execution pin <code>LessPin<\/code>, call <code>Context.GotoFixupRequestMap.Add<\/code> to register the destination of the execution control.<\/p>\n<p>In the same way, create a statement that transfers control of execution to the execution pin <code>GreaterPin<\/code>.<\/p>\n<p>Finally, the function <code>GenerateSimpleThenGoto<\/code> is called to create a statement that transfers control of execution to the execution pin <code>EqualPin<\/code> if none of the conditions are met (&quot;A=B&quot;).<br>\nThe function <code>GenerateSimpleThenGoto<\/code> is a convenience function that internally creates the statement <code>KCST_UnconditionalGoto<\/code> and calls <code>Context.GotoFixupRequestMap.Add<\/code> to register the pin to which execution control is transferred.<\/p>\n<h3>Register the Function Executed on the Execution Pin<\/h3>\n<p>The class <code>FKCHandler_MyCompareInt<\/code>, which defines the process of the execution pin, must be associated with the class <code>UK2Node_MyCompareInt<\/code> of the node.<br>\nThis can be done by overriding the member function <code>CreateNodeHandler<\/code> which returns the class <code>FKCHandler_MyCompareInt<\/code>.<\/p>\n<pre><code class=\"language-cpp\">FNodeHandlingFunctor* UK2Node_MyCompareInt::CreateNodeHandler(class FKismetCompilerContext&amp; CompilerContext) const\n{\n    return new FKCHandler_MyCompareInt(CompilerContext);\n}\n<\/code><\/pre>\n<h1><span id=\"Use_the_Created_Node\">Use the Created Node<\/span><\/h1>\n<p>Let&#8217;s use the node you created.<br>\nOpen the Blueprint Editor, right-click to display the menu, and enter &quot;mycompareint&quot; in the search box.<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/colory-games.net\/site\/wp-content\/uploads\/tech-blog\/nutti\/2022\/06\/20220626\/use_custom_node_search.png?ssl=1\"><img decoding=\"async\" src=\"https:\/\/i0.wp.com\/colory-games.net\/site\/wp-content\/uploads\/tech-blog\/nutti\/2022\/06\/20220626\/use_custom_node_search.png?ssl=1\" alt=\"Search for node &quot;MyCompareInt&quot;\" data-recalc-dims=\"1\"><\/a><\/p>\n<p>Select and place the node &quot;MyComponentInt&quot; in the category &quot;Flow Control&quot;.<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/colory-games.net\/site\/wp-content\/uploads\/tech-blog\/nutti\/2022\/06\/20220626\/use_custom_node_build_actor.png?ssl=1\"><img decoding=\"async\" src=\"https:\/\/i0.wp.com\/colory-games.net\/site\/wp-content\/uploads\/tech-blog\/nutti\/2022\/06\/20220626\/use_custom_node_build_actor.png?ssl=1\" alt=\"Create Actor\" data-recalc-dims=\"1\"><\/a><\/p>\n<p>When the created Actor is placed in the level, we can see that the execution result will be changed depending on the input values of the node.<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/colory-games.net\/site\/wp-content\/uploads\/tech-blog\/nutti\/2022\/06\/20220626\/use_custom_node_run.png?ssl=1\"><img decoding=\"async\" src=\"https:\/\/i0.wp.com\/colory-games.net\/site\/wp-content\/uploads\/tech-blog\/nutti\/2022\/06\/20220626\/use_custom_node_run.png?ssl=1\" alt=\"Execution of node &quot;MyCompareInt&quot;\" data-recalc-dims=\"1\"><\/a><\/p>\n<p>Here is the execution pin &quot;Greater&quot;.<br>\nYou can try to change the values of input pins &quot;A&quot; and &quot;B&quot;.<\/p>\n<h1><span id=\"References\">References<\/span><\/h1>\n<ul>\n<li><a href=\"https:\/\/docs.unrealengine.com\/5.0\/en-US\/compiler-overview-for-blueprints-visual-scripting-in-unreal-engine\/\">Blueprint Compiler Overview<\/a><\/li>\n<li><a href=\"https:\/\/docs.unrealengine.com\/5.0\/en-US\/API\/Editor\/KismetCompiler\/EKismetCompiledStatementType\/\">Unreal Engine C++ API Reference &#8211; EKismetCompiledStatementType<\/a><\/li>\n<\/ul>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>This article explains how to create a custom node with an execution pin.<br \/>\nWe assumes that you are familiar with the contents of the Basic section.<\/p>\n","protected":false},"author":2,"featured_media":592,"comment_status":"open","ping_status":"open","sticky":false,"template":"templates\/single-home-techblog.php","format":"standard","meta":{"footnotes":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":false,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[154,71],"tags":[177],"jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"https:\/\/i0.wp.com\/colory-games.net\/site\/wp-content\/uploads\/tech-blog\/nutti\/2022\/06\/20220626\/use_custom_node_build_actor.png?fit=888%2C467&ssl=1","_links":{"self":[{"href":"https:\/\/colory-games.net\/site\/wp-json\/wp\/v2\/posts\/1102"}],"collection":[{"href":"https:\/\/colory-games.net\/site\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/colory-games.net\/site\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/colory-games.net\/site\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/colory-games.net\/site\/wp-json\/wp\/v2\/comments?post=1102"}],"version-history":[{"count":11,"href":"https:\/\/colory-games.net\/site\/wp-json\/wp\/v2\/posts\/1102\/revisions"}],"predecessor-version":[{"id":1152,"href":"https:\/\/colory-games.net\/site\/wp-json\/wp\/v2\/posts\/1102\/revisions\/1152"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/colory-games.net\/site\/wp-json\/wp\/v2\/media\/592"}],"wp:attachment":[{"href":"https:\/\/colory-games.net\/site\/wp-json\/wp\/v2\/media?parent=1102"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/colory-games.net\/site\/wp-json\/wp\/v2\/categories?post=1102"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/colory-games.net\/site\/wp-json\/wp\/v2\/tags?post=1102"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}