Hello, I have a simple problem and I have no solution. I am trying to write a coroutine but I cannot make it work. Please see my image. The log will output always the last child five times.
@gavalakis, I dove deep into how to make the coroutines work and it is NOT as easy as I described in my post above (of course).
But, what would help, is for example having a flow maintain its own context.
This is most obvious with the ForEach example. Where with coroutines you get a wrong element.
I am not sure how to do this but this is the code from For each
`
foreach ( var o in li ) {
if ( broken ) {
break;
}
currentObject = o;
currentIndex++;
fCurrent.Call(f); // <- this is the issue
}
As you see, if the body of the flow is a coroutine it is working with incorrect data context as underlying variables change.
Thus “naively” it should be called with something like:
fCurrent.Call(f.Clone())
Where “Clone()” would create its own variable context for all output values of this node (i.e. keeping the value of “Current” in the ForEach bound to this branch of execution). The other options (less complicated I believe) would be:
fCurrent.Call(f, f.outputMap);
Thus the Call method will obtain outputMap which holds output values that will be fed into output ports.
This would allow for MUCH more dynamic programming.
Thank you for your input. I believe this has more to do with the implementation of the ForEach node (and similarily for the For Loop node).
I could implement a ForEach node to act the way you describe in your first post, however there is one problem: To continue with the next element in the iteration, we have to know when the current iteration has ended and there is no apparent way to know when a “flow” has ended since a node can have multiple output ports. Therefore for this to work, it will require implementing an extra Node (like a “Return” or “Continue” node), which will we will have to use at so that the ForEach node, knows when to proceed to the next element. In your example this “Return” / “Continue” node will have to be used right after the “Log Text” node for example.
Let me know what you think.
Thank you.
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.