Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Exiting 'If' statement

Discussion in 'Visual Scripting' started by PiotrMatczak, Aug 15, 2023.

  1. PiotrMatczak

    PiotrMatczak

    Joined:
    Apr 9, 2023
    Posts:
    3
    I want get visual scripting equivalent of this code:
    upload_2023-8-15_13-29-4.png

    However, I can't find equivalent of closing bracket or 'end if' for condition.

    In result, script below prints either both or neither messages.
    upload_2023-8-15_13-28-28.png

    How can I end 'if' condition without putting control statement at the end of control flow?
     
  2. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    4,362
    The Do Unrelated Stuff just has to go after the On Start. It's seperate from the if statement.
    Or you can call it after either true or false, but that might create more spaghetti
     
    PiotrMatczak likes this.
  3. tleylan

    tleylan

    Joined:
    Jun 17, 2020
    Posts:
    521
    I have never "dragged" a node of this language :) but "if test" then do something before "common thing" else do "common thing". So it looks like a line from if->False should be attached to the Print node for do unrelated stuff
     
    PiotrMatczak likes this.
  4. PiotrMatczak

    PiotrMatczak

    Joined:
    Apr 9, 2023
    Posts:
    3
    I'm looking for a way to enforce this specific order, that's why I specified I don't want to put control statement at the end of control flow. After all there might be situation where situation looks more like this:
    upload_2023-8-15_14-17-13.png

    However, after reading answers it seems like this setup would solve problem (although I would say it looks rather inelegant):
    upload_2023-8-15_14-19-13.png
     
    DevDunk likes this.
  5. tleylan

    tleylan

    Joined:
    Jun 17, 2020
    Posts:
    521
    It looks a tiny bit inelegant but you can move the the "do something" string node closer to the Print that uses it and line up the other string with the Print similarly. That is the "flow" BTW. If true just does something before it does the same thing that the false condition executes. There is no alternative.
     
  6. PiotrMatczak

    PiotrMatczak

    Joined:
    Apr 9, 2023
    Posts:
    3
    By "looking inelegant" I mean it looks weird from coding standpoint. Gives me feeling like I'm doing this:
    upload_2023-8-15_16-53-35.png

    In visual scripting I simply expected it to be grouped similarly to code block in C# like this:
    upload_2023-8-15_16-44-7.png

    But I expect it's completely readable for people working with it. Probably the case of being used to different visual representation on my side.