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:
My .cpp file:
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!
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:
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
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:
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)
Follow this question
Once you sign in you will be able to subscribe for any updates here