Search Unity

Visual Scripting For Content Creation

Discussion in 'Visual Scripting' started by Navarth, Jan 10, 2022.

  1. Navarth

    Navarth

    Joined:
    Dec 17, 2017
    Posts:
    21
    Hey everyone, I'm trying to decide on a visual scripting tool for my game - not as a C# code replacement, but as a tool to create scripted sequences, such as cutscenes, that require simple logic to string together game elements like animations, VFX, UI popups, and sounds.

    I've downloaded the Visual Scripting package, but it seems a bit heavy for my relatively modest needs, especially on domain reloads. Can anyone recommend an alternative? Is visual scripting even the right approach to this problem?

    What I'd like to do in specific is:
    • Create flow graphs of simple pre-programmed nodes that play animations, move objects, spawn particles, show UI dialogue boxes, etc.
    • Have simple logical branches dictate the flow (if/else, variable comparisons).
    • Nodes should be able to pause the flow until their operation completes (eg. an animation needs to finish or a keyframe is reached), or allow the flow through so several things can happen simultaneously.
    • Flow graphs are saved as assets and referenced by ScriptableObjects/MonoBehaviours, allowing the code to run them on demand from a C# script.
    • The graph should be able to be passed data when it's run, or able to access static data elsewhere - there's data like targets and damage values it needs to represent visually that won't be calculated in the graph itself.
    • Ideally, minimal performance impact outside of this system.

    If you've got any suggestions or advice, let me know! Thanks for your time.
     
  2. PanthenEye

    PanthenEye

    Joined:
    Oct 14, 2013
    Posts:
    2,065
    Try out Flow Canvas and/or Node Canvas. Last I benchmarked all the popular tools, Flow Canvas was the fastest and the most feature rich. Def faster than Bolt/UVS. I haven't ever touched Playmaker so no idea about that.

    There are also dedicated cutscene editors like Slate https://assetstore.unity.com/packages/tools/animation/slate-cinematic-sequencer-56558 so perhaps Visual Scripting can be skipped entirely. Slate also integrates with Flow/Node Canvas.
     
    Last edited: Jan 10, 2022
  3. Navarth

    Navarth

    Joined:
    Dec 17, 2017
    Posts:
    21
    Ah, those sound like great options. Using a cutscene editor is an interesting idea, though I'd want to make sure it's capable of branching and taking the game state into account, since I also intend to use it when characters use abilities. Slate's action nodes sound promising for this.

    I'm thinking of cases like the X-Com series, where a short dynamic cutscene follows every move and attack: the places the characters aim, shoot, and move are variable based on the game state.
     
  4. PanthenEye

    PanthenEye

    Joined:
    Oct 14, 2013
    Posts:
    2,065


    It appears you can trigger NodeCanvas actions from Slate's custcenes.



    And there's a ready-made Slate wrapper for Flow Canvas too. Flow Canvas, unlike Bolt/UnityVS has native callback support so triggering logic in graphs should be trivial. Flow Canvas/Node Canvas API is also really clean (unlike Bolt).
     
  5. Navarth

    Navarth

    Joined:
    Dec 17, 2017
    Posts:
    21
    @PanthenEye Thanks for the recommendation! I grabbed FlowCanvas and Slate and have been using them to some almost immediate success for this idea. I do have some more technical questions that maybe someone more familiar with FlowCanvas would know (I tried asking first on the Discord but so far no dice). If not, no worries!

    Firstly there's adding external data to the graph's blackboard from my code before running it. This works, but the code block I found it in implies AddVariable is deprecated. Is there a more correct way to do this?

    Code (CSharp):
    1. Blackboard bb = flowController.blackboard as Blackboard;
    2. bb.RemoveVariable("Test"); //Clear any data left over from last turn
    3. bb.AddVariable("Test", turn.actionData);
    Secondly, I'd like to treat this graph like a macro - load it via code, run it via code, wait for it to resolve, and continue with the rest of the code in the coroutine. Is there a simpler way to start the graph than sending a custom event like I'm doing here?

    Code (CSharp):
    1. Debug.Log("Animation Sequence " + turn.ability.onUseAnimation + " started.");
    2. bool sequenceRunning = true;
    3. Action<bool> seqCallback = i => sequenceRunning = i;
    4.  
    5. Blackboard bb = flowController.blackboard as Blackboard;
    6. bb.RemoveVariable("Test"); //Clear any data left over from last turn
    7. bb.AddVariable("Test", turn.actionData);
    8.  
    9. flowController.StartBehaviour(turn.ability.onUseAnimation, seqCallback);
    10. flowController.SendEvent("StartSeq"); //Send an event to execute the animated sequence graph
    11.  
    12. while (sequenceRunning)
    13.     yield return null;
    14. Debug.Log("Animation Sequence " + turn.ability.onUseAnimation + " complete.");
    upload_2022-1-16_22-24-5.png
     
    Last edited: Jan 17, 2022
  6. PanthenEye

    PanthenEye

    Joined:
    Oct 14, 2013
    Posts:
    2,065
    Try the FlowCanvas forums, the author usually responds within a few days. https://flowcanvas.paradoxnotion.com/forums/forum/root/general-discussion/