A For Loop that contains a While True won’t work properly. I made a simple example script that shows it. It should output the following sequence of numbers in the console:
The While node is not exactly a While loop but rather a coroutine while. This is done to avoid accidental user error with a result of hanging the editor in an infinite loop.
If you replace the While.cs code with the following code bellow it will come up with the results you want, but I am not really sure I this would be a good change to add for the reasons above. Maybe I can add an option in the node inspector for that.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
usingSystem.Collections;
usingParadoxNotion.Design;
namespaceFlowCanvas.Nodes{
[Name("While True")]
[Description("Once called, will continuously call 'Do' while the input boolean condition is true. Once condition becomes or is false, 'Done' is called")]
Sorry for another false bug report from me, it turns out that finding a real bug in FlowCanvas is not as easy task 🙂 Can you explain how the coroutine while works? If I understand it, perhaps I can find a way to use it without making the above change to the code.
No worries 🙂
Well, right now the While node works like a coroutine. Once the first flow signal is called on the While node, it starts a coroutine which calls “DO” only once every frame until the “Condition” input becomes false.
If the While node is called more times while the coroutine is still running, it is simply ignored. So only after the While node is done (and thus “Done” output is called), will another While loop be possible to take place for this While node.
So, probably due to how it works now, using While node as part of a For Loop will not really work as expected. I will probably need to add this option to do a real While loop (no coroutine) for such cases.
Let me know what you think and thanks! 🙂
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.