x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

How do I create my own blueprint node with C++?

Hey there, I have a basic question, how can I implement own blueprint nodes into the game. I added C++ code to my game which class type is "EdGraphNode". So it creates an .h and an .cpp file of my class. So this is the .h file:

 #pragma once
 
 #include "EdGraph/EdGraphNode.h"
 #include "MyEdGraphNode.generated.h"
 
 /**
  * 
  */
 UCLASS()
 class EDIFY_API UMyEdGraphNode : public UEdGraphNode
 {
     GENERATED_UCLASS_BODY()
     
 };
 

My .cpp file:

 #include "EDIFY.h"
 #include "MyEdGraphNode.h"
 
 
 UMyEdGraphNode::UMyEdGraphNode(const class FPostConstructInitializeProperties& PCIP)
     : Super(PCIP)
 {
     //
 }

I read that I have to implement this UFUNCTION in the files, but where? My tries to implement the line there where the // stands, that doesn't work for me. Please help!

Product Version: Not Selected
Tags:
more ▼

asked Sep 29 '14 at 06:16 PM in C++ Programming

avatar image

iUltimateLP
188 17 28 38

avatar image Moss Sep 29 '14 at 08:40 PM

I guess what you want is to create a new UK2Node?

avatar image Shadowriver Sep 29 '14 at 09:44 PM

You only do that if you want to create custom kind of node, most things can be solved by functions

avatar image Moss Sep 30 '14 at 07:14 AM

This is why I'm asking him, creating a new node is quite some work but gives you additional power on what you can do while being a very advanced topic.

avatar image Serellyn May 04 '15 at 08:54 PM
(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

It's pretty stright forward, you just make function like normally do in C++ and just mark it with UFUNCTION before it's decleration in with specific specifiers and UHT and reflections system will do the rest. Arguments of function will be inputs of node, arguments with refrence type (for example FString&) will be turned in to output, return value will also be output, if function is not static it will have "Target" input which you plug object on which you call the function on. UHT will add spaces to function and argument names before uppercase letters.

So for example:

 UCLASS()
 class EDIFY_API UMyNodes : public UObject
 {
         GENERATED_UCLASS_BODY()

         UFUNCTION(BlueprintCallable, Category="My Nodes")
         static int32 SomeIntReturningFunction(FString Text, int32 Number, FString& TextOut);
 
 };

Will create node named "Some Int Returning Function" node in category "My Nodes" (btw you can create subcategories with | symbol) which will have input for text and integer and text output as well as integer return output. Static will remoce "Target" input considering you making class for your nodes i assume you dont need that, or else you making nodes ofr perticilar class, then you need to place in to that class. You can use BlueprintPure insted BlueprintCallable so it will create passive node without action input output, you can also create events. here docs about this

https://docs.unrealengine.com/latest/INT/Programming/UnrealArchitecture/Reference/Functions/index.html

Lot of specifiers are not documented, you can explore wiki which has some examples, also i recommend you to explore engine source code to see how default nodes are declered, because they declered the same way, you can also find how they are declered in API refrence, here example Int + Int math which specially stylized math node and you already probably seen it in blueprints:

https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/Kismet/UKismetMathLibrary/Add_IntInt/index.html

Look of nodes made specially for blueprints are coded in UGamepleyStatics and UKismetMathLibrary, but practicly most gameplay classes has atleast few functions declered as nodes, they are marked with blue file icon in API refrece

You can expose C++ varables blueprint too with UPROPERTY(BlueprintReadWrite)

https://docs.unrealengine.com/latest/INT/Programming/UnrealArchitecture/Reference/Properties/index.html

more ▼

answered Sep 29 '14 at 06:47 PM

avatar image

Shadowriver
37.8k 937 172 1123

avatar image iUltimateLP Sep 30 '14 at 04:22 PM

Your function example doesn't work for me. It says this: Error 2 error LNK2019: Reference to non-resolveded external symbol ""public: static int __cdecl UMyEdGraphNode::SomeIntReturningFunction(class FString,class FString &)" (?SomeIntReturningFunction@UMyEdGraphNode@@SAHVFString@@AEAV2@@Z)" in Funktion ""public: void __cdecl UMyEdGraphNode::execSomeIntReturningFunction(struct FFrame &,void * const)" (?execSomeIntReturningFunction@UMyEdGraphNode@@QEAAXAEAUFFrame@@QEAX@Z)". C:\Users\Johnny\Documents\Unreal Projects\EDIFY\Intermediate\ProjectFiles\MyEdGraphNode.cpp.obj EDIFY

avatar image iUltimateLP Oct 01 '14 at 04:20 PM

Ok made it at my one.. Forget to do this void UTestEdGraphNode::TestFunction() {

 }

in my .cpp file

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

Also look in places in the engine source like

 (Your UE4 Install directory)\Engine\Source\Runtime\Engine\Private\KismetSystemLibrary.cpp

for good examples.

more ▼

answered Aug 06 '17 at 11:55 PM

avatar image

SND R Keene
988 31 120 113

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question