I’m learning about K2 nodes and have a couple of questions of how they work.
I can find most information about actually setting up a node from reading through existing K2 nodes just fine, however there are a few things that are unclear to me.
How does the actual logic that the node executes get called?
I get how to make the node, but it’s still not clear where the actual logic of the node is run.
Every tutorial and example I’ve seen seems to spawn and connect blueprint nodes through c++. Does it have to be done this way, or can you directly call c++ functionality?
Can can Array and Map pins pass by reference?
While you can technically set their pin types to take a reference, does this actually work for these variables?
There are two possible implementations of k2nodes. The first is the one that you’re familiar with which is using ExpandNode to spawn and wire up nodes in C++ very similar to something you’d have in blueprint. These nodes replace the node being expanded. The other option is using an FNodeHandlingFunctor which becomes part of the graph that is executed. I’ve done a lot with custom K2 nodes and still haven’t tackled the functor option. You can see examples in the engine with nodes like K2Node_Switch.cpp.
In the ExpandNode case, you’re only option for calling C++ functions are through spawning a K2Node_CallFunction node. There’s probably an option using the functor but probably more complicated than it’s worth.
Ultimately it’s not important. Blueprint has a custom virtual machine that steps through the graph and handles all the processing. As far as we (as implementers of k2nodes) the only thing that’s relevant is the logic of nodes that are placed down in the actual blueprint and those that replace custom nodes with other nodes.