Making custom nodes for Unreal is pretty easy when you know how to. You may be wanting to add some new functionality, make new features for your game or, simply, expose something to blueprints in the editor. I’ll show you how to make them but I’ll only be showing the Header file, the Cpp file isn’t needed right now. So let’s go over how to make some nodes!
Types of Blueprint Nodes
There are three main types of node you can create but all three have the same customisations, to an extent.
- Normal – This is a normal node with it’s execution pins. This one has a blue header and is the most basic of nodes.
- Pure – This one shows up with a green header, you’ll notice it doesn’t have it’s execution pins.
- Compact – This one is the smaller one without a header.
A Basic Node
Basic nodes are pretty basic which is why I call them basic…or normal. These are the ones with the blue header bar. They’re pretty simple to make. Mine doesn’t show the owning class below the header since I’m using a Function Library.
So, as you can see, this is pretty easy but let’s break it down anyway.
First, you, hopefully, know that anything being exposed to Unreal needs to have the UFUNCTION macro, for functions. This is so Unreal knows how to read it when compiling.
After that we have the node details, this is telling Unreal how to handle the node. Most of this is just cosmetic and most of it is optional.
Digging into the UFUNCTION, we have BlueprintCallable. This is telling Unreal we want to be able to call this function from Blueprints, pretty simple, isn’t it?
And we also have Category, which allows you to organise the node in any menu it may be in.
Then we have “meta“. Let’s go over what meta is. Anything within meta defines how the UFUNCTION interacts with the engine and editor but game logic cannot access the metadata, it’s purely visual in the editor.
As you can see, I can set a DisplayName which appears in the editor, along with Keywords to make it easier to find from search.
A Pure Node
As you may be able to tell, the main difference between this node and the normal one is the lack of execution pins and that’s about it for that one and there’s not much else to say about this node.
To have a Pure node, just go ahead and change BlueprintCallable to BlueprintPure.
A Compact Node
Compact nodes are compact, hence the name. They lack a header bar and tend to be smaller. They usually rely on a single word or symbol to tell you what they do. If you look at any maths nodes, you’ll see what I’m talking about. The maths nodes only use tend to use a single symbol which makes the compact nodes the way to go!
If you look at the meta, you’ll notice a new specifier called CompactNodeTitle. This tells Unreal to make the node Compact and that’s all you have to do, it’s pretty simple.
So lets go over some more specific stuff
Hiding The Input Of A Node
So you may notice some nodes have hidden input pins, like this one, and you want to know how to do this sorcery? Well, it’s pretty simple.
This is great as it cleans up the node slightly and you can just pass a variable in by reference. I left one input visible for reference.
To achieve this you first need to set the variable to be a const and add a & after the type, to define it as a reference parameter.
Lastly, I want to go over adding custom outputs to your nodes. Unfortunately, I only added a single output for my node but this method enables you to add as many as you want. First, let’s make the function return void, we can keep it as float but void will keep it neat for now. All you need to do is pass whatever variable you want to be an output as a reference, using &, and you’ll be good to go.
And that’s about it for now, you can read more about UFUNCTIONs and their properties here: https://docs.unrealengine.com/4.27/en-US/ProgrammingAndScripting/GameplayArchitecture/Functions/
If you’re interested in some more C++ tutorials, maybe check out:
Controlling What Happens on Fell Out Of World
Taking In-Game Screenshots With UI in Shipping builds of UE4 Games.