Search Unity

Switch flow every time node

Discussion in 'Visual Scripting' started by homerender, Aug 16, 2022.

  1. homerender

    homerender

    Joined:
    Sep 14, 2012
    Posts:
    189
    Hi everyone. Is there any node which can works like a Sequence node, but work not in parallel, but sequentially, first flow 1, then flow 2 and so on? I think I've seen this in some tutorial but I can't find it anywhere...

    Screenshot_12.png
     
  2. homerender

    homerender

    Joined:
    Sep 14, 2012
    Posts:
    189
    Found this one and it works, but I thought I seen some much more simpler node before and for any count of flows... Anyway it works for me for now.
    Screenshot_1.png
     
  3. PanthenEye

    PanthenEye

    Joined:
    Oct 14, 2013
    Posts:
    2,073
    Sequence does work sequentially unless they've changed that recently. You can test that with wait for seconds node, the previous flow will execute the wait before continuing to the next flow down the list. UVS is not multithreaded, so if it's not some kind of explicit async method, everything is executed sequentially, it can't run in parallel within the current architecture.
     
  4. homerender

    homerender

    Joined:
    Sep 14, 2012
    Posts:
    189
    Maybe I misunderstand something, but when i did that simple script and pressed a button (once) I seen that in the console :(

    Screenshot_1.png

    I just want to start next flow on the every next click.
     
  5. PanthenEye

    PanthenEye

    Joined:
    Oct 14, 2013
    Posts:
    2,073
    The order is correct, no? If they were truly parallel, the order would randomly change based on each flows contents.

    When any logic is triggered in a UVS graph, by default it'll execute all flow contents within the same frame. This includes sequence. If you want to delay execution of following Sequence flows, you have to manage that manually with Wait nodes such as Wait for Next Frame, Wait for Seconds, etc.
     
  6. homerender

    homerender

    Joined:
    Sep 14, 2012
    Posts:
    189
    Order is correct, just node Sequence works not as I want.

    I want to press the button and then Seq0 starts (ONLY Seq0). I pressing the button again and Seq1 starts. I pressing again and Seq2 starts. I pressing again - Seq0 starts again. That's all. It can be very useful but now I'm not sure is that possible out of box.
     
  7. PanthenEye

    PanthenEye

    Joined:
    Oct 14, 2013
    Posts:
    2,073
    That's a whole different thing. You need to track clicks in an Int object variable and use Switch On Int node to select the right flow to execute based on how many times a button has been clicked. Somewhere in the flow, add +1 to the click tracker object variable so the next click will switch to a different flow.
     
  8. Trindenberg

    Trindenberg

    Joined:
    Dec 3, 2017
    Posts:
    398
    I made a small edit to the Sequence node, into a Sequencer node. No idea if my code is correct as just edited in Visual Studio. But see if it works, not much to it really.

    SequencerDescriptor needs to go in an Editor folder.
     

    Attached Files:

  9. Welfarecheck

    Welfarecheck

    Joined:
    Jun 14, 2020
    Posts:
    120
    Use a variable with switch on integer.

    upload_2022-8-16_19-57-56.png
     
    screenracer likes this.