Search Unity

FlowCanvas (inspired by Unreal Blueprints)

Discussion in 'Works In Progress - Archive' started by nuverian, May 12, 2014.

  1. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    EDIT--This post is totaly re-written

    Hey,

    So, I am working on a new visual scripting NodeCanvas extension for some time now, and would like to share what I've been doing with you all :).
    The initial idea started off inspired by the node editor in XSI (ICE), but soon enough I kind of realized that this would rather not be very usefull as-is in a game development situation, which of course we are all after I presume.
    The reason I started with something similar to XSI's node editor for a visual scripting extension, was the freedom of data manipulation that is possible, compared to other purely game oriented designs existing for Unity right now. Without going to technical, the main difference is that it doesn't have the usual "In - Out" state like nodes, but instead all data are piped down to an Update call, very similar (visualy) to how you would create a shader in a visual editor.

    Softimage ICE Node Editor
    Long story short is that in a game dev environment, the above system:
    1. It may be costly for games.
    2. It's hard to read when it comes to flow control, like loops, conditionals etc which a game obviously is full of.
    3. Require more work to figure it out that it's worth, where instead you could go in and code the same thing. That is considering that a visual scripting tool is really there to bridge the gab between coder and designer, rather than replace either of the two!
    With that said, I love the ICE system and use it personaly, but I think something similar would not fit for visual scripting game logic.

    So, the next closest thing to XSI ICE node editor actually for game development, was clearly Unreal 4 Blueprint, Bitsquid Engine flowgraph and at a lesser degree CryEngine's flowgraph, which combine a visualy forward execution state-like behaviour together with backward data fetching.

    Blueprint, like ICE, also provides some very low level control, but there are some pros and cons by having this control or not.

    Putting this to test, I came up with this. (Of course color coding things is now mostly missing)
    1.png
    In this first case, we can directly pass data around and there is no need to store it somewhere temporary, although we could if need be. Furthermore there is both great flow and data manipulation control. The downside is that a real graph might easily become a spageti, where in pure code it could be just a 2 liner.

    2.png
    In this 2nd approach, there is hardly any low level control and we can't directly pass data around, but instead need temporary storing, which also needs to take place "within" the flow design by executing rather than getting (eg 'Get Property'). The obvious good thing is that its much cleaner and probably more focused by not exposing all funtion arguments and return value as ports

    Then again, at first glance it seems that the initial purpose of data manipulation is defeated without exposed ports.

    In a way, we could combine the 2 designs above to get some good points from both worlds, by using 'compounds'. Or in other words, a handfull of nodes compounded into one with specific exposed ports.

    (This image is a proof of concept in photoshop)

    4.png

    And then use and reuse the compound node to make the higher level graph cleaner and focused.
    3.png

    This seems like a good aproach, but on the other hand, this compound node could be made into a simple function in code and then use an Execute Function node like the rest. So this is a point where I am skeptical about.
    In the end it comes down to how low or high level control to exist. In both cases I hope this to become a very versatile tool in the overal steps of blueprint :)

    So, this is what I am working on and my thoughts on the matter shared with you.
    What do you think? Do you have any ideas that want to share? Would you prefer one aproach over another? Would such a tool be useful to you?

    Implementation wise, this is already working more or less except the compounds, UI color coding and some other thingies I will post in time. If you have any question feel free to ask :)

    Cheers!
     
    Last edited: Nov 28, 2014
  2. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    [space]
     
    Last edited: Nov 28, 2014
  3. SteveB

    SteveB

    Joined:
    Jan 17, 2009
    Posts:
    1,451
    Well I for one (as you know nuvie) will be following this! :D
     
  4. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    Thank you Steve for your support!
     
  5. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    Hey everyone,
    I've totaly re-written the initial post with more in depth information.
    I'd be glad to hear your thoughts.

    Cheers!
     
  6. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    So, here is a feature on debugging the graph, which I presonaly like :)
    You can selectively debug view any 'Value Port' for it's current or last value in runtime. This is shown on top of the connection within the editor window like bellow:

    Debug Values.png

    I think having a visual debuging info "in-place" like this, really helps things when it comes down to creating some bigger graphs.

    More comming soon :)
    Cheers!
     
  7. inas

    inas

    Joined:
    Aug 2, 2013
    Posts:
    47
    Excellent! Nice one

    Is this will be sold as a separate package from NC?

    Would love to see gif version of visual debugging
     
  8. Elecman

    Elecman

    Joined:
    May 5, 2011
    Posts:
    1,372
    I just bought NodeCanvas, but a bit to soon I think. I am investigating several approaches for simulating complex aircraft systems. I had a quick play with NodeCanvas but it appears it is not really designed for what I want to do as the simulated systems look a bit awkward using the current BT or FSM approach. For example, I can't even add a simple AND, OR, or NOT gate. But that is a BT/FSM limitation I suppose.

    I want to make the visual representation as close as possible to the real (simplified) electric / logic schematics available and avoid using the sequencer / selector approach as these are not representative of real world hardware. Lines between nodes should be able to carry boolean or float values, so simulation of pneumatic, hydraulic, and electric systems is possible.

    It looks like the new extension you are working might be the thing I am looking for although the removal of AND / OR gates in your latest example has me slightly worried. Also, the possibility to change the graphics of the current generic square node would be a plus. This way it would have a closer resemblance to schematic logic gates, hydraulic reservoirs, etc.

    Does it make sense what I am trying to say and would do you think that the thing I am looking for is feasible?
     
  9. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    Hello :)

    Yes, this will be a seperate package than NodeCanvas. Either an extension or a standalone. It still depends.
    Here is a quite silly gif example for the shake of showing some animated values:
    FG_Debug.gif

    This will of course be improved, but want to focus on the core first :)

    Hello,

    You are definetely making sense, don't worry :)
    The existing NodeCanvas package doesn't include this system. NC (as you figured out) has a Behaviour Tree and HFSM implementation modules, which work and achieve things quite different than what you are after.
    The WIP I am showing here is a separate module, build on NodeCanvas core framework.

    This system, can indeed carry different (any) type of data across.
    The AND was not removed in the last image. I was showcasing the concept of putting (nesting) a couple of nodes inside "compound nodes". So in the last image of the first post, the AND is included in the "Can Open" compound node. Again, this is a concept, which I haven't really done yet. So, AND, OR etc low level nodes, as of now, are included.

    As far as changing the shape of the node, unfortunately I think that will be quite hard to do, but a node can have an icon instead, which is better than nothing :) For example:
    Bool.png



    As a final word, I would like to let everyone know, that the direction (purpose) of this tool might change in time and based on feedback or ideas provided. For the time being, I am focusing on creating a quite general data flow node editor, able to handle most situations which are common between any such node editors.

    Cheers!
     
  10. gurayg

    gurayg

    Joined:
    Nov 28, 2013
    Posts:
    269
    Hello,

    What I would like to know is your estimation about this tools performance (Not the editor, its runtime performance)
    Is it able to produce scripts or does it simply work at run-time?
    If it produces scripts; Do you think it'll be feasible to add a custom code node, so anyone can insert some code snippets into the flow.

    Thanks
     
  11. inas

    inas

    Joined:
    Aug 2, 2013
    Posts:
    47
    From your vision, what will this flow node main use in the future?

    From what i know of nodecanvas:
    • BT - decision making, AI
    • HFSM - stateful process, simple decision making
    • Dialogue Tree - non linear dialogue data
    Is flow node will be a general purpose visual programming helper? Maybe could become a nested node on BT/FSM. Almost removing need to open monodevelop?
     
  12. Elecman

    Elecman

    Joined:
    May 5, 2011
    Posts:
    1,372
    @nuverian,
    Sounds good! That icon will do the trick. It is all about "instant readability", so that would be fine. Some more feature requests:

    -Ability to stretch the icon to the background of the node and add the ability to slightly adjust the position of the line contact points to align int with the icon.
    -Save a custom node for later use.
    -Ability to change the icon with a simple API so that it can for example display an open or closed valve or switch.
    -Simple animation on a node to visualize data such as a pie or bar, to be used for time, volume, etc.
    -Nodes capable of running a script on the input and outputs instead of having pre determined behavior.
    -Visual grouping of systems with each their own input and outputs. For example, create a bunch of nodes which represent an engine. Then group all these nodes together, call the large square "Engine", and give it input "bool start" and "float friction", and output "float RPM".

    @inas,
    Not sure what the supposed "main" usage would be but it would be perfect for mechanical/electrical system simulation. Remember that Unity is not only used to make games, as can be seen here:
    http://unity3d.com/industries

    Other then systems simulation, it is also just another way of doing things which in my opinion is more intuitive.
     
    Last edited: Dec 5, 2014
  13. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    Hello,

    No scripts are created from the system, no. It "simply" works in run-time, and very fast for that matter :)
    The reason of the fast performance is that when it comes to actually running the graph, the implementation behind is very close to how it would be in code.

    What I mean, is that there is really not much between 2 ports execution. An Out call and an In method are directly binded and thus calling Out.Call() in the 1st node is essentialy calling method In() of the 2nd node directly, since '.Call' is a System.Action which has been assigned the method 'In' of the 2nd node.
    Node1.Out.Call = Node2.In

    The same thing also happens for value ports as well, but instead this time it's a System.Func<object> instead. So for example when an AddFloats node 'asks' for FloatA.value, '.value' returns directly the value of a method that is in the node which 'FloatA' is connected to.
    Node2.FloatA.value = Node1.Result

    Thus, there are also no runtime assignments. An output value is fetched when and only it is asked for.

    When in Unity Editor only (#If UNITY_EDITOR), the connection is also added inbetween these getters to show the debug information as shown in previous post.

    I hope I didn't get very technical here :)

    Now, as far as adding in your own code, you don't really have to create a custom node for that, since any function can be used as a node through reflection, which reflection is also turned into delegates through expression trees for performance instead of using Invoke which is slow.
    So there is a single node which can wrap any function.
    - Each parameter of the function is turned into an input value port.
    - If the function has a return value, that value is turned into an output value port.
    - out parameters (like for example in Physics.Raycast hitInfo) are also turned into output value ports.

    Here is what I mean. This is probably not how the UI will be in final, but for the shake of demonstration:

    Func.gif

    This node can also wrap static functions, in which case the "instance" port will not exist.
    Similarly, properties are also accesible.

    Hello inas,

    Yes, you are prety much spot on of the purposes of the current systems in NodeCanvas and this is a very interesting question :)

    This system started heavily inspired by XSI's ICE as I state in the first post, which is purely a data flow editor. Later on ideas from unreal blueprint were introduced (basicaly event driven forward state-like excution. See In-Out ports ), for a more game development centric application.
    As it currently stands, it will be a generic visual scripting editor, yes, but it might also change direction to become something more specific but certainly related to visual logic and/or behaviour.
    For example if I see that it leads to creating fully spaggeti graphs to achieve something rather easy, then I might reconsider it's purpose to be more meaningful, direct and usable.

    No matter what direction it takes, it will certainly be fully compatible with the rest of NodeCanvas systems in one way or another. Having nested flow graphs is one way :)

    Now with that said, I never thought of any visual scripting tool as something to completely replace coding for a full project, but as something to bridge the gap of coders and desingers and organize thought into structure. At least to me, this is what a visual scripting editor is about :)
    This also prety much wraps the vision about this, as well as the other systems :)


    Hey,

    I am prety much obsessed with instant readability myself :)
    Let me give you some answers regarding your requests:

    - Having the icon as a background could be something possible, but aligning will probably not be :)
    - A node is a class, within where you define it's functionality and looks. What do you mean by saving custom node?
    - I will take a look at switching icons. It might be easy.
    - A node can display anything (Unity GUI) inside it by overriding OnNodeGUI in the node class. So graphs, pies, bars can be possible.
    - By running a script you mean something like my first answer of this post where you can use any function as node?
    - Yep, this is prety much the "compounds" I've been talking about, showcased as a proof of concept in the first post. I really like this and I hope to manage achieving it :)


    Cheers everyone!
     
    Last edited: Dec 5, 2014
  14. Vectrex

    Vectrex

    Joined:
    Oct 31, 2009
    Posts:
    267
    Looking cool. I like the debug values.
    I personally would love something more like http://scratch.mit.edu. Where you're mostly just assembling actual code (with real C# being written behind the scenes, which you can edit if you want) in a block format, which is unbreakable. You could also type and make it as fast as typed code.
    You could then use the idea of 'nodes' and wires, more like functions. Where the execution path is a wire, but the individual blocks can just snap vertically like typed code execution path.
    So you'd end up with 'nodes' of clusters of blocks, which are collapsible (just visibly, not separate), connected to each other and other components with wires.
    I actually really hate Blueprints, even though I love modular environments for audio work. They're way too messy without any real functionality to justify it. They all need more snapping and auto flow inference with the OPTION to split them apart into branching wires.
     
  15. Elecman

    Elecman

    Joined:
    May 5, 2011
    Posts:
    1,372
    I meant that if you make a custom node, say an AND gate with 5 inputs, it would be nice to be able to post it somewhere so other people can use it as well.

    Yes, but not just a Unity build in function, but a function I made myself.
     
  16. HeadClot88

    HeadClot88

    Joined:
    Jul 3, 2012
    Posts:
    736
    Hey,

    I am a heavy user of unreal blueprints so you have my attention.

    Will we be able to make full games with this tool?

    This is one of the MAJOR advantages of Unreal Blueprint Systems.

    Integration with things such as Unity Networking/Unet and the like would also be appreciated :)
     
  17. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    Hello Vectrex,

    Glad to see you here. You helped me quite a bit in NC :)

    What you are proposing here is a very different system altogether. It's hardly a node based editor :)
    Furthermore I would like to let you know that there IS a Unity plugin like scratch. It's called 'plyBlox'. Haven't used it but it looks cool.

    I agree that Blueprints can become messy without justificaion, yes. I am trying to get that messyness away somehow, if at all possible. One way I am thinking, is to encapsulate code within nodes without much port exposition (2nd image in 1st post), thus simplifing the graph. But on the other hand port exposition allows for data flow in case scenarios like Elecman posted. In the end I think I am going to allow both ways. Low and High level.

    Yes, of course. Once this is out, I will create a repository for nodes at the official site.
    Also, yes, you can run any function including from your own code, not just Unity built in ;)


    Hello there,

    This is a prety vague question, but as it stands now, you will be able to achieve what blueprint can. If you can make a full game wholy with blueprints, then this system will most probably allow the same.
    Personaly though, I think that there is no such thing as creating a full game without writing a single line of code, unless it's a very simple one :)

    Cheers :)
     
  18. inas

    inas

    Joined:
    Aug 2, 2013
    Posts:
    47
    nuverian,

    I absolutely loves your idea of nodes repository! Is it open source? Maybe hosted on Github? Can the community contribute custom node or sample tutorial? NC will become strong platform if supported by many people :)

    Ps: my username is nascode on your NC forum :)
     
  19. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    Oh, hey nascode ;) How the JRPG battle system is going?

    I am still investigating the best approach of a nodes repository, so that it is definetely community driven.
    One way is the per-se open source repository like you describe (github or bitbucket). More apealing to coders.
    Another way is something from within a Unity editor window, possible to download/upload nodes. More apealing to non-coders.
    (same thing for tasks as well)

    The 2nd is more difficult for me, due to my limited networking knowledge :p

    Both have pros and cons, but the idea is the same :)
     
  20. Elecman

    Elecman

    Joined:
    May 5, 2011
    Posts:
    1,372
    Sounds like the thing you are working on is exactly what I need. Unfortunately it is not finished yet ;-)

    I also had a look at uScript but it doesn't support AND/OR/NAND/XOR/Switches either. Do you know something that is currently available which can do such a thing?

    By the way, I hope you don't go fully blueprint style. This is how NOT (no pun intended) to do it:
    https://answers.unrealengine.com/questions/21407/blueprint-and.html
    I am already seeing our engineers going WTF over this.
     
    Last edited: Dec 6, 2014
  21. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    Glad to hear :)
    I hope to finish it soon.

    I don't really know something currently available, no. and this is prety much the reason I've started this in the first place :)

    The answer given in the link seems quite confusing for no reason indeed. Let me give you a clear example that is close to what you are after:

    AND.png
    So, the red Update node, is an "initiation" node. It could be something else like an event for example. OnUpdate, SetActive is called. SetActive has a boolean parameter and we provide the required boolean with a oversimplified "circuit".
    So, if both bool1 and bool2 are true, the light will be active, but if either is false the light will not be active.



    I've also came up with some new possible ideas I will try. I will keep you people posted :)
     
  22. Elecman

    Elecman

    Joined:
    May 5, 2011
    Posts:
    1,372
    Excellent! Can't wait :)
     
  23. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    Hello everyone,
    I would like to share with you how a node class is currently defined, especialy in regards to it's ports. When it comes to ports, there are basicaly two types of ports those being the Flow ports and the Value ports.
    Flow ports are those responsible for the forward based execution flow. Commonly "In"/"Out".
    Value ports are those used for moving data within the graph.

    So, there are basicaly two different ways for defining and using those in a node class, which I like to call 'direct' and 'indirect' ways.

    Direct Way
    The direct method is based on declarations and the use of attributes.
    This is an example of the simplest node with one In and one Out flow ports.
    Code (CSharp):
    1. namespace NodeCanvas.FlowGraphs{
    2.  
    3.     public class Example : FlowNode {
    4.  
    5.         [RegisterPort]
    6.         public FlowOutput Out;
    7.  
    8.         [RegisterPort]
    9.         public void In(Flow f){
    10.  
    11.             //do something here...
    12.             Out.Call(f);
    13.         }
    14.     }
    15. }
    Example1.png
    Notice the 'Flow' parameter in the 'In' method. This is not mandatory to use and it may contain various data. A node can use it, alter it, or simply pass it along like above.
    A FlowOutput can have only one connection, but a FlowInput can have any number of connections, which also make sense.


    This is the simple example of a node adding 2 floats and exposing the result:
    Code (CSharp):
    1.     public class Example : FlowNode {
    2.  
    3.         [RegisterPort]
    4.         public ValueInput<float> A;
    5.         [RegisterPort]
    6.         public ValueInput<float> B;
    7.  
    8.         [RegisterPort]
    9.         public float Result(){
    10.             return A.value + B.value;
    11.         }
    12.     }
    Example2.png

    Notice that this node doesn't have any Flow ports, because it doesn't really need to be executed to do the sum. It simply returns the sum through the 'Result' port whenever it's asked for. Simple as that :)
    In reverse to the FlowPorts, a ValueOutput can have any number of connections, but a ValueInput, naturaly only one connection.

    Indirect Way
    Some times you may want to add the ports after the fact. For example after the user has made some settings in the Node Inspector panel. This is something that I do in the case of the 'Function' node for example, which creates the ports based on the function selected in the node inspector.

    Doing the first node with the two In/Out ports this way would be like this:
    Code (CSharp):
    1.     public class Example : FlowNode {
    2.  
    3.         protected override void RegisterPorts(){
    4.             AddFlowOutput("Out");
    5.             AddFlowInput("In", In);
    6.         }
    7.  
    8.         void In(Flow f){
    9.             //do something here...
    10.             Call("Out", f);
    11.         }
    12.     }
    So basicaly you override the RegisterPorts method and register any node port in there. Notice that in this case, there are no fields declared at all, cause in reality none is needed. The only declared member is the method that defined what happens when the flow reach the 'In' port of this node.

    The second example node (Add floats) with the indirect register way looks like this:
    Code (CSharp):
    1.     public class Example : FlowNode {
    2.  
    3.         protected override void RegisterPorts(){
    4.             AddValueInput<float>("A");
    5.             AddValueInput<float>("B");
    6.             AddValueOutput<float>("Result", Add);
    7.         }
    8.  
    9.         float Add(){
    10.             return GetValue<float>("A") + GetValue<float>("B");
    11.         }
    12.     }
    Again, notice that no declaration apart from what the 'Result' port returns is needed here, which is the only one realy needed.

    So, both ways of registering ports are important and have their use, with the first (Direct) being slightly faster.
    In the end, everything is very easy to define and use, works very fast as well as in my opinion, intuitive :)

    Needless to say, you can of course mix Flow and Value ports. Here is an example of the Branch node using the first way:
    Code (CSharp):
    1.     public class Branch : FlowNode {
    2.  
    3.         [RegisterPort]
    4.         public ValueInput<bool> Condition;
    5.         [RegisterPort]
    6.         public FlowOutput True;
    7.         [RegisterPort]
    8.         public FlowOutput False;
    9.  
    10.         [RegisterPort]
    11.         public void In(Flow f){
    12.             if (Condition.value) True.Call(f);
    13.             else False.Call(f);
    14.         }
    15.     }
    Branch.png
    Last but not least, there are various ways to customize the node using attributes or by overriding methods and properties, for defining it's icon, category, help description, custom node inspectors etc.
     
    Last edited: Dec 9, 2014
  24. Elecman

    Elecman

    Joined:
    May 5, 2011
    Posts:
    1,372
    Can the node be modified via the right click context menu as well? For example, adding pins (where it makes sense), changing name of the pins, changing the icon, etc.

    One other question. Would it be possible to have a node which represents the position of a multi-position rotary switch, with an ENUM as an output? And how would you hook that node up to the GameObject?
     
    Last edited: Dec 10, 2014
  25. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    Changing the icon and port names in the editor is currently not possible, but changing the names will definetely be.
    Through the Node Inspector panel you can add extra pins to the nodes that makes sense, although whether or not a node supports and how to handle this, is totaly up to the node definition.

    Regarding you 2nd question, you can use the Switch node, either "Switch Int" or "Switch Enum":

    SwitchInt.png

    Depending on the input 'Index' the coresponding Out port will execute. You can add any number of FlowOutput pins.


    SwitchEnum.png

    'Status' is an enum for this example. The Switch Enum currently lists all different values of Status. These are automaticaly gathered when you select the Enum type you want to switch from within the SwitchEnum inspector panel.


    In both of the above cases the index or enum inputs could of course be provided however you like.
    For example:

    SwitchInt2.png
    Or the value can be taken from a Blackboard Variable. I haven't really talked about them here, but those using NodeCanvas already prety much know what I mean :)
    In essence you are able to get, set and generaly manipulate local and global variables within the flow graph.

    SwitchVariable.png
    I hope this covers your question. If not let me know.

    Cheers!
     
  26. Elecman

    Elecman

    Joined:
    May 5, 2011
    Posts:
    1,372
    Thanks, that definitely clears that up :)
     
  27. Cynicat

    Cynicat

    Joined:
    Jun 12, 2013
    Posts:
    290
    This looks really interesting but the main limitation i see is the fact its a runtime system. that means you can't extend classes, make interfaces or do any of the cool stuff you can with code. still looks really awesome though. depending on its feature set i may even use it over my own system. love the UI by the way. really clean and easy to read. =3
     
  28. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    Hello Cynicat,

    Thanks :), I am glad you like it so far.
    I'm not sure what you mean though. The system is very extendable, possible to create your own nodes, custom variable types, custom events etc. Furthemore is designed to work with your code as seamless as possible.
    Can you elaborate on this?

    Thanks and happy new year (soon) :)
     
  29. Cynicat

    Cynicat

    Joined:
    Jun 12, 2013
    Posts:
    290
    I mean extending a code class using visual scripting similar to how ue4 blueprint works. i'm currently working on a system to generate c# scripts using a graph. downside is i cant change it at runtime. upside is better performance, easier feature adding, code nodes, etc... however since i just restarted development on my solution it will be a while before its ready for use. so if this does what i need it too i would be happy to use this instead as its looking really cool. =3
     
  30. rahuxx

    rahuxx

    Joined:
    May 8, 2009
    Posts:
    537
    need beta tester?
     
  31. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    Hello,

    Thanks for clarifing. Indeed making a virtual function that is extended in visual scripting editor is not possible. Some of the other things explained here, are though somehow possible using reflection.

    Hello,
    Thanks for your interest. I will post about it when it's beta ready here. It's not far from now :)
     
  32. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    Here is a small but important update as far as creating nodes.

    Creating most nodes is has been very simplified by extending 2 base classes: ActionNode and FunctionNode.
    ActionNode is similar to System.Action and FunctionNode is similar to System.Func delegates and they are also declared very similarily. For example:

    Code (CSharp):
    1. public class Log : ActionNode<string>{
    2.     public override void Invoke(string text){
    3.         Debug.Log(text);
    4.     }
    5. }
    Log.png

    Code (CSharp):
    1. public class LerpVector : FunctionNode<Vector3, Vector3, Vector3, float>{
    2.     public override Vector3 Invoke(Vector3 from, Vector3 to, float t){
    3.         return Vector3.Lerp(from, to, t);
    4.     }
    5. }
    Lerp.png


    The params keyword is also supported. If a parameter is a params array, then the node will have controls for adding/removing ports relative to the params array.

    Code (CSharp):
    1. public class AddFloats : FunctionNode<float, float[]>{
    2.     public override float Invoke(params float[] f){
    3.         var result = 0f;
    4.         for (int i = 0; i < f.Length; i++)
    5.             result += f[i];
    6.         return result;
    7.     }
    8. }
    AddFloats.png

    An ActionNode is the equivalent of a 'Callable' node in Unreal Blueprint, while a FunctionNode is the equivalent of a 'Pure' node in Unreal Blueprint for those familiar with them.

    Of course, any existing function or propery is already available through reflection and can be turned into a node automaticaly, but the more frequently used ones, are best to be created using this way.

    Finaly, the use of attributes (as shown couple of posts above) has been totaly removed in favor for a more streamlined workflow.
     
  33. Cynicat

    Cynicat

    Joined:
    Jun 12, 2013
    Posts:
    290
    This is looking really cool! sign me up for the beta when one happens. it will be so nice to focus on Design driven gameplay again. i love unity but its so technical i feel trapped by it sometimes. one question i have(no pressure) is are these editable at runtime? such as if i wanted to make a UI for players to make there own scripts? i understand if this isn't possible but it would be really bad-ass. =3
     
  34. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    Hey,

    If you mean whether its possible to show the UI in the build game as a game UI for players, then no, that is not possible, sorry :) There are a lot of editor only stuff used for the editor.
     
  35. Stridemann

    Stridemann

    Joined:
    Oct 12, 2013
    Posts:
    251
  36. Morfeuskiev

    Morfeuskiev

    Joined:
    Oct 10, 2013
    Posts:
    122
    Hi. I have a question:
    1) Can i create function?
    2) Can i create Class?
    3) Can i to connect to class, created in your Visual Editor from c# script?
    4) Do you have all class and methods of Monobehavior?
    5) Can i connect to c# script class?
    6) Do your script have entity? the same as c# scripts? Can i throw this "virtual script" to another prefab, object, etc, the same as c# script and can i write only one (original) entity of script, and have changes on all gameobject who used this entity?
    7) Do your system have tabs? Or two levels tabs for function and class in script?

    Thanks in advanced.

    With best Regards, Leonid
     
  37. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    Hello Leonid,
    Regarding your questions:

    1. If you are refering to self-contained group of nodes like in unreal blueprint, this will be possible after the beta release yes.
    2,3. Can you please clarify what you mean?
    4. Every method in any class can be accessed and be used as a node, yes.
    5. Can you please clarify what you mean by 'connect'?
    6. Yes, you can reuse the same visual script created on any number of game objects.
    7. When the self-contained group function nodes (1) are implemented, it will be possible to navigate through them with breadcrub style navigation, yes.

    Let me know of your other questions if you like :)

    Cheers!
     
  38. Morfeuskiev

    Morfeuskiev

    Joined:
    Oct 10, 2013
    Posts:
    122
    nuverian

    Thanks for answers.

    2, 3) In standard c# script we can, create methods (aka functions), create our public class, we can make public or private variables, etc. In future in another script we can used this created class (inherit). In my question i called this "connect". So, my question is strong but easy: Can we inherit Public Class, or method IN C# Script, from script created in your Visual Script System?

    In 4 question i mean that access to all Unity Script API (aka Inherit from Monobehavior).
    http://docs.unity3d.com/ScriptReference/

    5 question i mean that access to variables from c# script (not visual) aka Call method.

    6) So, do your system has entity? C# script is very ease to edit, so when we make any change in script, this change automatical has affect on all object, who used this c# script? You will have something similar?

    When beta period is over? When i can try your visual script system?

    Thanks. With best Regards, Leonid.

    P.S. And one more question: How will the work with public variables in the inspector? The same as in c# script?
     
    Last edited: Jan 19, 2015
  39. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    @Morfeuskiev

    I will start by explaining that the system does not compile into a script. It rather works in runtime. The focus/goal of the system is not ment to replace coding for programmers, but rather to "replace" coding for designers and non-progammers, and as an effect allow programmers and designers to work together easier and faster.
    The programmer is able to define some events that happen in the game and the designer is able without coding, through the system, make use of those events and define what happens, without requiring the help of the programmer other than the events definition for the most part, and extra nodes if need be.
    As such, a graph has no notion of a class in the assembly that can be inherited for example. You can certainly extend the FlowGraph class for creating custom graphs, but not in the sense that you describe.

    I hope this answers your 2nd & 3rd questions :)

    Regarding Unity's API, all the unity API and your own, is available through reflection.

    5. You can easily access the variables used in the graph from code with 2 simple functions: GetDataValue & SetDataValue

    6. A FlowGraph is assigned on a gameobject similar to how you assign for example a Mecanim AnimatorController to an Animator Component, where all changes made to the orginal AnimatorController will affect every game object on which it has been assigned to.

    The beta period is not yet started, but it will soon. I will post about it here :)

    As for your last question. All variables are exposed in an inspector yes.

    Cheers!
     
  40. inas

    inas

    Joined:
    Aug 2, 2013
    Posts:
    47
    Hi @nuverian

    It's february, would like to know how is the progress on your visual scripting :)
     
    Cynicat likes this.
  41. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    Hello,

    Im working on some major refactors of NodeCanvas, the core on which this system is build as well and shortly after that, this will be available. Within Febuary :)
     
    Cynicat likes this.
  42. Cynicat

    Cynicat

    Joined:
    Jun 12, 2013
    Posts:
    290
    yay! if it turns out well i won't have to roll out my own system! \\^-.-^//. quickly let me test your things!
     
  43. robin-fischer

    robin-fischer

    Joined:
    Aug 21, 2014
    Posts:
    8
    Hello nuverian,

    Again I have to say, this looks great. I am really looking forward to Beta/Release!


    Runtime or Code Generation

    I prefer a runtime System that does not have to recompile every time you change something. Also this makes changes during PlayMode possible. Often Reflection or overly usage of Invoke makes the System slow. Especially on Mobile and AOT Devices (Consoles). Maybe You or We [Source Included. Yay :)] could implement Code Generation for Builds. But that is still to be seen.


    Feedback on the Editor

    I really like the 'Compound' System that you presented in your first Post. Encapsulating Nodes is not new, but with Parameters it makes a very powerful way to define lightweight 'Methods' for non-Programmers.

    How are you implementing the 'Compound' System regarding sharing of the Encapsulated Nodes? Will those Compound Nodes be added to the normal Node Collection? Maybe there should be an own Tab for the Nodes that where created via Encapsulation. Are you storing the Entries for these Nodes in a .asset File. And if yes, how will that work with Version Control, if multiple People add Compound Nodes to the Collection.

    Visual Debugging and Value Peeking looks great. Also the coloring will be very helpful. Are you doing some stress Tests for large Scale Projects? Often the EditorGUI in Unity suffers when the Object Count goes up.

    It is great that multiple Out Ports can be defined dynamically! This is a very important Part for Actions with variable outcome. As you described already Switches are a great example.


    Extending the System

    Am I reading this the correct way? So we have 2 Options to define Custom Nodes:

    - Using the 'Indirect Way' that you described in your Post from Dec 9 2014
    - Using the ActionNode<> and FunctionNode<>

    If this is correct. It is a good way to easily extend the System. Although I probably would always choose the 'Indirect Way' in case I want to extend a Node.


    Are you referring to the Beta or a Release?


    Again I am looking forward to this Plugin :)


    Best Regards,

    Robin
     
  44. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    Hey, Let's hope it does :)
    I will let you know for a test run :)

    Cheers!

    Hello and thanks a lot :)

    I also prefer runtime over code generation personaly. Generating code from the graph could be possible although honestly it's something I havent looked at (like ever), but yep, full source code is included :)

    The compound nodes will be saved as .asset files yes and will be shown as part of the nodes list to add under a respective category. When it comes to version control, as with any asset file in Unity, unfortunately its either a "keep" or "discard". There can definetely be alternatives to this, which I will explore once I fiddle with this part of the system more :)

    Up to my current tests the systems run quite fast. Traversing the actual nodes (executing and getting data) by itself is fast, so it's more of what you throw at it to do :)

    Regarding the output ports, yes it's quite possible, but it's up to the node definition of course if it's possible at all. For example the Switch node, has a list of outputs which basicaly from the GUI it's possible to Add/Remove outputs.

    Yes, there are basicaly 2 ways of defining a node. The 'indirect way' is far more flexible and better at defining more complex nodes than those simply doing a function call, while the other is better for simple nodes. I presonaly prefer the first in any case.

    Regarding Febuary, I was refering to the beta version release on the asset store if all goes well, which will be determined by some closed beta testing before that. Let me know if you are interested.

    Cheers and thanks for your feedback :)
     
  45. robin-fischer

    robin-fischer

    Joined:
    Aug 21, 2014
    Posts:
    8
    Hi nuverian,



    I have contacted you via PM.





    It works quite well with small .assets when they are forced to Text Serialization (Yaml) but, yeah that is true. I was rather referring to the way the System Collects these Compound Nodes. I see three general options: Asset Labels, Fixed Folder Path or a Database that lives in a .asset and has to refresh when new .asset get imported (2D Toolkit does it this way. But it takes ages to scan all .assets).

    Thats cool. How about Editor Performance? This should not happen in a well thought Environment, but we probably both know that this is not always the Case. What happens when throwing 1000 Nodes on a Canvas?

    Robin
     
  46. bilke

    bilke

    Joined:
    Jul 13, 2012
    Posts:
    54
    Hi nuverian,

    this looks very promising! I am also very curious on the upcoming beta although my possible use case is quite a bit different as you intend but I think it would be a good fit: I would like to represent a visualization pipeline (interconnected visualization algorithms with in- and outputs) with this tool.

    Thanks for your awesome work!
     
  47. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    Hey,
    I am still not sure what you mean on how it's collecting the .asset, but basicaly, the "Compound" assets are fetched with a simply FindObjectsOfTypeAll when there is a reason to fetch them, like for example showing the context menu for selecting one to add into the flowgraph.

    Regarding 1000 nodes in editor, Im currently more focusing on the runtime efficiency rather the editor one, but generaly speaking a node is only drawn when it is within the window area. Right now, 1000 nodes, slows down the editor quite a bit :)

    Hey there!
    Glad you like thus far. I think that with this tool (at least in its final form) you could represent most things that communicate data with input and output ports :)
    As for the beta, it's not far. Possibly within this week.

    Cheers!
     
  48. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    Hey everyone. Here is a nice update.
    At long last I managed to implement the Compound nodes (also known as Macros in Unreal).
    Here is an example:

    FlowGraph.png
    The above is the main FlowGraph. It simple Logs the distance of the Owner game object and the game object that entered the trigger. The highlighted node "Get Distance" is though a 'Macro Compound' reference.


    And this is the actual macro compound graph defined once and reusable anywhere.
    GetDistance Macro.png
    The ports also are exposed to the parent node inspector and are assignable directly in case we don't want to connect something. (in this case since the inputs are a GameObject type and the graph is an asset we can't assign a reference anyway)

    Of course its a silly example, since it would be best if such a primitive task would be a single implemented node in the first place, but still an example for what it's worth :)

    Let me know what you think or you have any suggestions, ideas etc.
    Cheers!
     
    robin-fischer, cubez and Pajaroide like this.
  49. bilke

    bilke

    Joined:
    Jul 13, 2012
    Posts:
    54
    Do you have any news on a release date? If not would it be possible to participate in the beta? Thanks!
     
  50. Stiffx

    Stiffx

    Joined:
    Oct 27, 2014
    Posts:
    455
    I like to code but this is a really good project, maybe for those new users or designers who doesn't like to code at all.
    Tip: you just have to think like non coding users, try to think about common routines we do everyday and add those to your project the most easy way. With that said I think you can have a good selling product. Cheers