Is there a way to do a node with exactly three outputs. I see that if I inherit Decorator, then I’ll have one output, if I inherit Composite node, then I can have as many as I want, but they are dynamic. I’m trying to create a node that goes through 3 states during execution. I want to attach three nodes to very specific slots which will execute during each state change.
Well, you can kind of contrain the possible connections but they would still be as you called them ‘dynamic’, meaning that they will fill up as you add them and not keep their connected index.
You do that you can derive from BTComposite for example and override:
virtual public int maxOutConnections{get;}
By the way, you can also override the following if you want to hook the new connection/node to something:
virtual public void OnPortConnected(index int)
virtual public void OnPortDisconnected(index int)
Again, the connections/ports UI will work the same but you will be able to hook up to 3 connections for example. Their indexes will still be autosorted.
Let me know of your node use case so that I can provide more help with it, although generaly speaking in the context of behaviour trees I haven’t ever seen any node type with a very specific amount of childs 🙂
virtual public void OnPortConnected(index int)
virtual public void OnPortDisconnected(index int)
this exactly what I need. Can I rely on the index variable to ensure that first connection does X, second does Y and third does Z. For example in case if I need to only use first and third I could connect an empty action to the second slot.
To clarify – my characters have a list of abilities. Each ability has three states (cooking, performing, cool down). Depending on the ability I may need to perform some action during the start of each state. Ability is one node, that goes through each state internally.
The OnPortConnected and OnPortDisconnected indexes are the indexes of the nodes that were just connected or disconnected, but since nodes are resorted in editor based on their relative position to the parent, you can’t rely on that index.
The correct indexes to rely to would be that of the outConnections property, which is what is used to execute the child nodes if you you take a look at any existing node.
So in ‘OnExeute’ of the node, outConnections[0] will be the first connection, outConnections[1] the 2nd and so on.
But I wonder, why would you want such a node. I mean you could use a Selector and 3 child nodes decorated with an Accessor. So based on the condition of the Accessor execute either of the child nodes of the Selector.
Unless I misundertood something 🙂
Let me know
Join us on Discord: https://discord.gg/97q2Rjh
Author
Posts
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic.
Login
Register
By registering on this website you agree to our Privacy Policy.