I created a custom UK2Node that (1) makes requests to a remote server, and (2) asynchronously fires outputs as soon as we have a response from the server.
The node was implemented by extending UK2Node_BaseAsyncTask. Here’s how it looks like:
In this case, I use the input exec pin to make the server request. Everything works beautifully!
I would like to make my node to work without input exec pins.
That is, my server requests would be done under the hood as soon as the game starts (e.g. BeginPlay). Like an input key node, no input pins would be displayed. Outputs would stay as they are (i.e. fired whenever we have a response from the server). Something like this:
Would you have any idea on how I could implement this?
PS: I spent some time studying the classes UK2Node_InputKey & UK2Node_InputKeyEvent, but I’m still not sure how they transfer to my case. Maybe I’m missing some background info on how they work?
PPS: I also posted [the same question in the forums] as I was not sure where would be best place for it!
You need to think it outside of box, in blueprint editor technically nodes are only UI elements. are same as code text, all they are is mainly UI data, they only track what is connected to what and based out of that data it build VM code. So you can do anything that Slate and Graph Editor widget (which is not only used in Blueprint) allows… so practically anything. UK2Nodes are only used in editor once they compiled inrmation about them in the VM is destroyed as it not really needed to execute it. It like you have ability to write any text in to C++ and make compiler integrate it whatever you like
So technically you should approach to UK2Node more like to a UI widget class (in fact they are graph editor widget system components) then a code piece that does something. Once you understand that making node without pin should sound trivial for you.
The initial set of pins are set up in AllocateDefaultPins function using CreatePin function, so you should override it and create pins that you need and pins same as nodes are just UI widgets, alone they not much functional. So making pin not appear is as trivial… as doing nothing ;p After that function is executed, you can access pin object and manupate them on varous events in K2Node
And it not just pins K2Node ocntrols all aspects of node appearance, title bar, it color etc and oyu also have option to create your own slate UI in it as node widget all together. that what i’m saying UK2Node is more like a widget then code piece
Thanks a lot for your answer, @anonymous_user_f5a50610!
I already have a customized K2Node. This node has its custom appearance, title bar, output pins, etc, and I’m able to visually get rid of the input pin (by using RemovePin() inside AllocateDefaultPins(), for example). However, if I just get rid of the input pin like this, my node will never get executed (i.e. the node will never make a server request and never fire outputs).
I would like to modify this node so that it is able to fire outputs without requiring input exec pins. Consider, for example,the nodes K2Node_InputKey and K2Node_InputTouch. While they do not have input pins, they will fire outputs as soon as there are key or touch events. That’s what I’m looking for!
I tried to investigate these classes. Each of them use complementary K2Node_*Event class (e.g. K2Node_InputKey & K2Node_InputKeyEvent) that helps them to get the job done. However, the logic starts to get more abstract and confusing to me (e.g. K2Node_InputKeyEvent uses InputKeyDelegateBinding that uses an array of BlueprintInputKeyDelegateBindings…). Maybe someone could give me a hand here?