Search Unity

Question Best way to make systems with visual scripting?mak

Discussion in 'Visual Scripting' started by TheKrazyDev, Dec 2, 2022.

  1. TheKrazyDev

    TheKrazyDev

    Joined:
    Sep 8, 2021
    Posts:
    107
    So lately I've been trying to make some bigger projects and been trying make systems to make my life easier, like making a gun system to easily make new missions or whatever. But what's the best way to make systems? Like with c# you have classes and scriptable objects and etc, but what about vs?
     
  2. PanthenEye

    PanthenEye

    Joined:
    Oct 14, 2013
    Posts:
    2,067
    Essentially, UnityVS does not have a structure, it's entirely free form. There are no class or scriptable object alternatives in VS. Perhaps look into Composition vs Inheritance debate. Inheritance is not possible with UnityVS but you can try to apply some composition concepts to visual scripting since an object can have any amount of FlowMachine components on it and you can do graph nesting via subgraphs which is also the only way to reuse some of the graph code. There are HasScriptGraph type nodes which let you execute some logic if a GameObject has some graph on it.

    There's also the StateMachine graph which can be used for various things like managing UI flow, managing game state, AI, etc. But there's nothing past the FSM graph, subgraph and HasScriptGraph node concepts. That's literally it. They've talked about implementing Interfaces a couple years back, but I wouldn't hold my breath for it. It's not on the roadmap.

    Visual Scripting is not meant to be a full C# code replacement, it's made to be complementary. The expectation from Unity is that game architecture is still handled by C# coders and only designer and artist types would use Unity Visual Scripting in proffessional capacity.

    Doesn't mean you can't make games fully in VS, it's just that it's harder because it lacks a lot of capabilities C# has. And there is no intent from Unity to change or improve that.

    EDIT: You can also do a fair bit with UVS custom events. When both the target and the receiver GameObject references match, an event will trigger. You can use a central GameObject and point most if not all Custom Events to it as some central event manager object. Personally, I dislike custom events since they're entirely loose string based and there's no way to know how many events are defined or where. Albeit Node Finder from the asset store helps with that.
     
    Last edited: Dec 2, 2022