Dual output nodes

Zefugi 2 years ago updated by Lazlo Bonin (Lead Developer) 2 years ago 10

So I have a flow macro that checks for the existatnce of a scriptable object on a given gameobject. Basically I'm checking if a component exists. If so, i return the boolean result of a C# method, and if not, I return false. Or so I thought...

When I run this in a flow machine, I sometimes get the wanted result, and sometimes not. The macro simply locks on to the first active output node, and keeps serving it's result regardless for every subsequent call.

Below is a shot of the macro in action. As you can see, the upper Output node is being activated, but the output value Has Tag is being fed from the lower Output node, giving a wrong result.

I've checked that the component exists on the Game Object at the activation time of the macro, and that it has the correct tag object, and everything checks out. But this is besides the point: The point being that data is clearly flowing forward from the wrong node.

In addition to the bug report, I would like to know if there is a different way of passing different data nodes forward based on a null check (or any other dual-control-flow-output node)?

Bolt Version:
Unity Version:
Scripting Backend:
.NET Version (API Compatibility Level):
Pending Review

The short answer is that dual output nodes are not supported. There's no way to know which one you want to prioritize, because output nodes are not restricted to having a single control point (as in your graph), because they're not traditional functions: they're really sub-graphs.

The reason why there isn't a warning or error telling you that at runtime is related to performance. Checking for multiple output nodes and erroring out is actually a lot more expensive than taking the first output node in an undefined order.

I could add a warning at edit time however that colors the output nodes in yellow if you have more than one in the graph.

Re: passing data forward from dual output, there isn't a built-in unit for this at the moment. You could however create your own super unit with two control inputs, two value inputs, and one control input, one value output, and do the association in there. I'm not at work yet so I don't have Bolt open, but if you want I could give you an example later.

The marking of dual output nodes as yellow/errorous would be nice, in that noone else will think dual nodes are going to work. :)

I'm not sure exactly how the super unit would work, so an example would be greatly appreciated.

Not a Bug

Ah, so indeed, this was a mind bender for a second. The trick is to use the And unit, because it short circuits:

Here for example, Compare Tag will never be called if the first condition is false, therefore it won't be called if the object is null.

(I didn't have your exact nodes, so I used similarly named ones, but I think you'll understand the underlying logic!)

Thanks. That is quite a peculiar workaround, but if it works you won't hear me complaining.

..though I would suggest a node that takes two control flow inputs and two data inputs, and outputs one control flow and one data - the data would be the first or second data input, based on which of the control flow inputs are used. Either that or a null check that outputs a boolean.I think that would be more intuitive.

By the way. I couldn't find custom nodes (make using C#) in the roadmap. Are you planning such a feature or do you think relying on C# methods will be sufficient?

Your new unit idea is very interesting, could you post it in a separate Idea thread? It really helps me keep track as I'll close this issue once warnings are added.

It's already possible to make custom units, but there's no documentation about it. The manual page for that is planned on the roadmap between v.1.4 and v.1.5. Although quite a few users have already started diving into the code with trial and error. You can ask for help on that topic in the #scripting-api channel of the Discord server!

I've had too much boardgame & rum tonight, but I'll make an idea post tomorrow. And I'll check out the channel too. :)

Fixed in Beta


Added a warning for v.1.3b2.