Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

NodeCanvas - (Behaviour Trees | State Machines | Dialogue Trees)

Discussion in 'Assets and Asset Store' started by nuverian, Feb 8, 2014.

  1. nuverian

    nuverian

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

    I've finaly submited version 2 to the asset store. Sorry for the over due delay, but I was having some other matters troubling me.
    I've also just send out NC v2 to everyone who have requested it in the meantime :)

    @hippocoder Thanks as well! Please PM an email if you want me to send it to you. There is also an online API docs comming online just when it goes live, which is something I remember you specificaly requested above all, and of course it's a great thing to have :)

    Cheers and have fun!
     
    inas, iviachupichu, Pajaroide and 2 others like this.
  2. Vectrex

    Vectrex

    Joined:
    Oct 31, 2009
    Posts:
    267
    Love the new features. There's a few bugs with CSharp events though (at the bottom)
    Here's my notes

    Canvas Groups (nit picky stuff)
    - Nested groups don't drag children.
    - Hierarchy move leaves behind groups.
    - Can be made super tiny (eg ctrl clicking, without moving)
    - If a node is slightly outside the group, it's not in the group anymore. It might be better the other way round? Hmm

    Misc questions/issues
    - Only composites have breakpoints. Why's this? Also the play/pause/next buttons aren't in the editor, which I thought you mentioned they were?
    - Delete key won't delete more than one node, even if more are selected (Right click delete works fine)
    - Variable bind: Can this bind to vars not in it's own GO? My GO's are made up of lots of children.
    - When you add a new node with a wire, select it automatically (like right click adding one)
    - Is there an Interrupt composite? Or is that just Dynamic? How does the interrupt node work? For example, if his health<1 then immediately do a new branch and ignore timed stuff running.
    - It would be cool to be able to right-click on a line and insert appropriate nodes. Or drag an unconnected node onto a line (like Nuke)
    - FlipSelector: It'd be nice to have an invert button, so failed branches go last (eg a fighting game where a hit fails, so he tries a kick)

    Actions
    - Utility/Debug
    - None of them display text above the GO anymore. This was really handy.
    - Debug variable: It would be nice to display the variable name then the contents in the log (eg now a bool just says 'true' in the console)​

    CSharp events
    - Don't work for static events. I use a lot of static events for world event broadcasting.
    - For statics it'd be great to be able to drag the code file itself as the target (since statics still work with no GO instances in the scene. So accepting "Object")​

    - Don't work.. AT ALL :)
    - Here's my event test​

    public delegate void Simple();
    public event Simple OnTest = delegate { };

    void Update()
    {
    OnTest();​
    }

    My graph was a simple sequencer with one condition and action

    Here's the two log dumps. The infinite loop one repeats.

    InvalidCastException: Cannot cast from source type to destination type.
    System.Reflection.EventInfo.AddEventFrame[EventTest,Simple] (System.Reflection.AddEvent`2 addEvent, System.Object obj, System.Object dele) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Reflection/EventInfo.cs:174)
    System.Reflection.EventInfo.AddEventHandler (System.Object target, System.Delegate handler) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Reflection/EventInfo.cs:100)
    NodeCanvas.Tasks.Conditions.CheckCSharpEvent.OnInit () (at Assets/NodeCanvas/Tasks/Conditions/ScriptControl/CheckCSharpEvent.cs:40)
    NodeCanvas.Framework.Task.Initialize (UnityEngine.Component newAgent, System.Type newType) (at Assets/NodeCanvas/Framework/Tasks/Task.cs:374)
    NodeCanvas.Framework.Task.Set (UnityEngine.Component newAgent, IBlackboard newBB) (at Assets/NodeCanvas/Framework/Tasks/Task.cs:335)
    NodeCanvas.Framework.ConditionTask.CheckCondition (UnityEngine.Component agent, IBlackboard blackboard) (at Assets/NodeCanvas/Framework/Tasks/ConditionTask.cs:45)
    NodeCanvas.BehaviourTrees.ConditionNode.OnExecute (UnityEngine.Component agent, IBlackboard blackboard) (at Assets/NodeCanvas/Modules/BehaviourTrees/Nodes/Leafs/ConditionNode.cs:32)
    NodeCanvas.Framework.Node.Execute (UnityEngine.Component agent, IBlackboard blackboard) (at Assets/NodeCanvas/Framework/Graphs/Node.cs:232)
    NodeCanvas.Framework.Connection.Execute (UnityEngine.Component agent, IBlackboard blackboard) (at Assets/NodeCanvas/Framework/Graphs/Connection.cs:158)
    NodeCanvas.BehaviourTrees.Sequencer.OnExecute (UnityEngine.Component agent, IBlackboard blackboard) (at Assets/NodeCanvas/Modules/BehaviourTrees/Nodes/Composites/Sequencer.cs:27)
    NodeCanvas.Framework.Node.Execute (UnityEngine.Component agent, IBlackboard blackboard) (at Assets/NodeCanvas/Framework/Graphs/Node.cs:232)
    NodeCanvas.BehaviourTrees.BehaviourTree.Tick (UnityEngine.Component agent, IBlackboard blackboard) (at Assets/NodeCanvas/Modules/BehaviourTrees/BehaviourTree.cs:66)
    NodeCanvas.BehaviourTrees.BehaviourTree.OnGraphUpdate () (at Assets/NodeCanvas/Modules/BehaviourTrees/BehaviourTree.cs:52)
    ParadoxNotion.Services.MonoManager.Update () (at Assets/NodeCanvas/_ParadoxNotion (shared)/Services/MonoManager.cs:41)


    <b>Graph Error:</b> 'Infinite Loop Detected' On node '<color=#bf7fff>SEQUENCER</color>' ID 1 | On graph 'BehaviourTree'
    UnityEngine.Debug:LogError(Object)
    NodeCanvas.Framework.Node:Error(String) (at Assets/NodeCanvas/Framework/Graphs/Node.cs:240)
    NodeCanvas.Framework.Node:Execute(Component, IBlackboard) (at Assets/NodeCanvas/Framework/Graphs/Node.cs:220)
    NodeCanvas.BehaviourTrees.BehaviourTree:Tick(Component, IBlackboard) (at Assets/NodeCanvas/Modules/BehaviourTrees/BehaviourTree.cs:66)
    NodeCanvas.BehaviourTrees.BehaviourTree:OnGraphUpdate() (at Assets/NodeCanvas/Modules/BehaviourTrees/BehaviourTree.cs:52)
    ParadoxNotion.Services.MonoManager:Update() (at Assets/NodeCanvas/_ParadoxNotion (shared)/Services/MonoManager.cs:41)




    Actually, I deleted the graph and made a new one, this time an asset. It won't let me change the target. I presume this is because it's not part of the scene. There's no instance changes allowed with this?

    This Graph doesn't handle drops of type 'Transform'
    UnityEngine.Debug:Log(Object)
    NodeCanvas.Framework.Graph:OnDropAccepted(Object, Vector2) (at Assets/NodeCanvas/Design/PartialEditor/EDITOR_Graph.cs:409)
    NodeCanvas.Framework.Graph:AcceptDrops(Event, Vector2) (at Assets/NodeCanvas/Design/PartialEditor/EDITOR_Graph.cs:403)
    NodeCanvas.Framework.Graph:ShowGraphControls(Event, Vector2) (at Assets/NodeCanvas/Design/PartialEditor/EDITOR_Graph.cs:125)
    NodeCanvas.Editor.GraphEditor:OnGUI() (at Assets/NodeCanvas/Design/Editor/Windows/GraphEditor.cs:296)
    UnityEditor.DockArea:OnGUI()
     
  3. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087

    Hey Vectrex,

    Thanks. Glad you do. Here are some answers:

    Canvas Groups
    - I dont understand what you mean regarding nested groups and children dragging :?
    - Moving the nodes hierarchicaly will not force the group to move cause it might containg other nodes irelevant of the node hierarchy. Basicaly the Canvas Group moves only if yo move it and will move every node within it.
    - I tried the other way around at first, (moving nodes even slightly contained in the group) and it was way confusing :/, but if more people agree that nodes should be considered in group even when slightly inside, I can do it this way.
    - Yeah I will fix not being able to add tiny groups

    Misc
    - Only composites having a break point was just an organization preference decision, I can add it this option in all bt nodes.
    - Regarding the play/stop/pause within editor, I said I will add it :) but unfortunately didnt find the time to do so. It's still in the TODO list.
    - Alright, I will fix delete key, deleting all selected instead of only through context.
    - Regarding Binding Variables target GO, I made this way to be more clear and have a more streamlined workflow (i love streamlined workflows ), instead of showing a GameObject field in the blackboard. I would realy create a wrapper component for the child components in deed in the base game object and bind those wrapper properties instead.
    While it's possible to set the target go, I realy want to avoid exposing a GameObject field :/
    - Alright, I will auto select new nodes created out of new connection context
    - You can use the Interruptor Decorator to interrupt child node based on a condition. Is that what you mean?
    Alternatively, yes, you could use the Dynamic option.
    - I had some thoughts on inserting nodes between connections, but had some issues mostly GUI wise. I will take a look at this again though.
    - Yep, nice idea. I will add that option in FlipSelector.

    Actions
    - Indeed the Debug Log no more shows a label basicaly cause there is no OnGUI callback received anymore.
    I will think about forwarding OnGUI calls or an alternative way to show a label, since I agree it was realy handy.
    - Sure, I've added Debug Variable to show the name of the variable as well.

    - The CheckCSharp condition task, is very tricky. Currently it works with events of Action:
    public event System.Action SomeEvent;
    I will take a look at this again (plus static events), and hope I can find a solution :)

    Yes, Assets, generaly speaking, can't reference scene objects and the ObjectFields is turned grey (disabled) to indicate this further.
    You basicaly either have to use Local Graphs (which is somwhat like prior v2 workflow), OR, use Blackboard variables to set the parameters, since the blackboard is a component living in the scene's gameobject of the GraphOwner, unless you have that graph owner as a prefab too, in which case you also cant reference scene objects in a prefab since a prefab IS an asset.
    There is realy no other way around it. I mean this is just how unity works :)


    Cheers and thanks!!
     
    Marble likes this.
  4. Vectrex

    Vectrex

    Joined:
    Oct 31, 2009
    Posts:
    267
    Canvas Groups
    - I dont understand what you mean regarding nested groups and children dragging :?

    Ah, if you have a canvas group INSIDE another one, he gets left behind :)


    - Moving the nodes hierarchicaly will not force the group to move cause it might containg other nodes irelevant of the node hierarchy. Basicaly the Canvas Group moves only if yo move it and will move every node within it.

    That could be fixed by checking if all the nodes in a group are moving/part of the hierarchy. Then you could move the canvas with it.

    - I tried the other way around at first, (moving nodes even slightly contained in the group) and it was way confusing :/, but if more people agree that nodes should be considered in group even when slightly inside, I can do it this way.

    Yeah, probably would be. Maybe try 50% So 51% inside means it's in the canvas?


    Misc
    - Regarding the play/stop/pause within editor, I said I will add it :) but unfortunately didnt find the time to do so. It's still in the TODO list.

    Hah, sorry. I thought I was missing an option somewhere :)

    - Regarding Binding Variables target GO, I made this way to be more clear and have a more streamlined workflow (i love streamlined workflows ), instead of showing a GameObject field in the blackboard. I would realy create a wrapper component for the child components in deed in the base game object and bind those wrapper properties instead.
    While it's possible to set the target go, I realy want to avoid exposing a GameObject field :/

    Yeah I see what you mean and thought that was why. Would it be too messy to allow a GO to be dragging directly onto the bind button? Then pop up the current list, just pointing to the other GO's components. Then just display *GOName/Component/Var*?... cropped obviously ;)

    - You can use the Interruptor Decorator to interrupt child node based on a condition. Is that what you mean?
    Alternatively, yes, you could use the Dynamic option.

    Yeah I think so. I'll do more testing.

    - I had some thoughts on inserting nodes between connections, but had some issues mostly GUI wise. I will take a look at this again though.

    Yeah it's a tricky UI. Maybe you could bring back the selectable thing you used for inline conditions. But for inserting nodes?


    Actions

    - The CheckCSharp condition task, is very tricky. Currently it works with events of Action:
    public event System.Action SomeEvent;
    I will take a look at this again (plus static events), and hope I can find a solution :)

    Ah yeah, Action works. Without static I'm wondering how I could even get the BT to react to world events? hmm, let alone sort out if it's interested from parameters/EventArgs


    "Yes, Assets, generaly speaking, can't reference scene objects and the ObjectFields is turned grey (disabled) to indicate this further......."

    Yeah, but with normal prefabs, when you instantiate one in a scene, you're free to adjust individual variables, which remain unique to that object, while everything is still linked to the prefab. In the BT I thought it'd work the same, such as to allow that particular instance of the BT on a GO to hook up to things in scene.
    Actually Prefabs let you do this to some extent. If the reference is to another GO which is also part of the prefab, it lets you do it.
    It's a tricky one.
     
  5. nuverian

    nuverian

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

    Oh. I will see fixing this then. To be honest didnt thought of nested groups :)

    Sorry but I think this will not be implemented. :/ The nodes know nothing of the group they belong.

    I will give this a try.

    Will take a look at this. Probably allow a selection through the whole hierarchy.

    What selectable thing? :)


    Well, instead of the CheckCSharp condition I would recomend using the CheckEvent<T> condition. You can SendEvent to the graph from code even with an argument in many ways, one of them being:
    owner.SendEvent(new EventData<float>("eventName", 14f));

    or send a global event:
    Graph.SendGlobalEvent(new EventData<float>("name"), 14f);

    Using the CheckEvent<T> condition you can catch this event and optionaly store the event value if you want to.


    Well, actually the Bind Graph option is partialy doing this. You have a graph asset and you Bind it to a GraphOwner in the scene. From now on you are free to adjust the graph in a local level and thus possible to also reference scene objects. Changes made to the binded graph are not made to the asset graph.
    Alternatively if you dont want to bind the graph, you can work with Blackboard variables which allow scene references since Blackboards they live in the scene, unless you made it a prefab as well :)

    Thanks!
     
    Last edited: Mar 10, 2015
  6. Vectrex

    Vectrex

    Joined:
    Oct 31, 2009
    Posts:
    267
    Um, how do I use prefabs now? If I make it a local asset, it's not part of a prefab. But if I make it a separate asset, then I can't reference my own child GO's. This would work ok if you allow child GO references to be stored, otherwise I can't use v2 at all really.
    I assumed local meant the same as before (but I thought the child GO was just hidden)
     
    Last edited: Mar 10, 2015
  7. nuverian

    nuverian

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

    Your assumption is partialy correct that Local is realy ment to be same as before, with the difference being that there are no more GOs for graphs. Instead Graphs derive from ScriptableObject now.

    With that said:
    - The problem with the local graph not being part on the prefab when you create one, is now fixed.
    - As well as the ability to reference object from the prefab hierarchy is also fixed.
    So basicaly it works like before now :)

    I can send the version to you if you like. (it also has some other fixes and improvements)

    Cheers!
     
  8. Vectrex

    Vectrex

    Joined:
    Oct 31, 2009
    Posts:
    267
    Ah great. Thought I was going nuts :) Yeah send it along, thanks. Octamed g mail
     
  9. username132323232

    username132323232

    Joined:
    Dec 9, 2014
    Posts:
    477
    Hey Nuverian,

    I've been using NodeCanvas 1.6.1 FSM in my game for several weeks and it worked as expected. Yesterday, for whatever reason, the game stopped working. After hours of troubleshooting I realized that FSM starts before Awake() of the main game control script. This is really weird since I haven't touched FSM for a while. Do you have any idea why this is happening?

    Thanks in advance!
     
  10. Unib0t

    Unib0t

    Joined:
    Jan 4, 2013
    Posts:
    15
    I'm trying out the 2.0 release in a test project, and have encountered two issues so far:

    1) When I add an Execute Function action to an FSM and try to select a method with no parameters, the method isn't added and I get the following error:

    InvalidOperationException: not a generic type definition

    Methods with one or more parameters can be added without a problem, and if I add a dummy parameter to the method it appears to work correctly (although not ideal). Is this a bug, or is there some rationale behind this?

    2) The 'Use Self' checkbox in Execute Function now doesn't appear until a method is selected, which means you need to first add a temporary method from the current object before being able to select a method on another Game Object.

    EDIT: (found a third issue)

    3) When an Execute Function action calls a method with a return value, it causes the following error:

    NullReferenceException: Object reference not set to an instance of an object
    NodeCanvas.Tasks.Actions.ExecuteFunction.OnExecute () (at Assets/NodeCanvas/Tasks/Actions/ScriptControl/ExecuteFunction.cs:73)

    This happens with my own methods as well as the ones built into Node Canvas.
     
    Last edited: Mar 11, 2015
  11. inas

    inas

    Joined:
    Aug 2, 2013
    Posts:
    47
    @nuverian congrats v2 has been released on assetstore

    Is docs on nodecanvas.com has been updated for v2?
     
  12. Randhall

    Randhall

    Joined:
    Feb 21, 2013
    Posts:
    17
    Hey I'm loving the updates to the version 2.0 (although i just started playing with it so we'll see if it's all good in a while ;) )
    One thing I''m missing is a small feature that would reset your view to the root node with a press of a button.
    Sometimes when you close the editor with the nodes out of the view for any reason from silly resolution change to something more crazy you have no reference to where your content in the graph is. If it would be possible to hit 'Home' button or any other button at that matter that would take you to the root node immediately that would make it so much easier ;)
     
  13. Randhall

    Randhall

    Joined:
    Feb 21, 2013
    Posts:
    17
    Oh it's already there ;) never mind then "F" is my new best friend :D
     
  14. RDeluxe

    RDeluxe

    Joined:
    Sep 29, 2013
    Posts:
    117
    Hi,
    I just updated to version 2 and I'm trying to port my FSM and boards. However I don't find how I can create variables of a custom type in my blackboard, via the editor (i.e I have a character class and I want to create 2 character variables in my blackboard, and also a enum linked to a specific enum, etc).
    We managed to do it in 1.6, but I'm stuck ...

    Edit ; The type configurator, of course ... my bad !
     
    Last edited: Mar 11, 2015
  15. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    Hello everyone, well you got me first in this. Version 2 is live on the asset store :)

    Sure will do. Just need to fix some things I've encountered while doing this possible. Thanks.

    Hey,
    The GraphOwner starts the graph OnEnable. This might indeed be problematic in some cases, so it would be better to do this OnStart I suppose. Please open up GraphOwner.cs and change OnEnable to Start for now.
    Alternatively you can put GraphOwner in a positive number in "ProjectSettings/Script Execution Order" (or yours in a negative of course). Generaly speaking though I try to avoid Script Execution order window.
    Thanks! I will fix this properly in next version.

    Hello,
    All your reports are totaly valid and indeed bugs, retalted to ExcuteFunction and script control tasks.
    I fixed them all now :)
    Will push the update soon.
    Thanks!


    Thanks!
    I am updating the documentation as we speek :)

    Hey, Thanks.
    Yep "F" focus the graph :)

    Hey,

    Dont worry :)
    Yes the Type Configurator is very important window.
    Furthermore notice that you can create a blackboard variable by clicking the small "+" bellow the dropdown when you are to select a variable. So if you have a task with a BBParameter<MyOwnClass> and you press that "+" you will add a variable of MyOwnClass type to the Blackboard :)
     
  16. iviachupichu

    iviachupichu

    Joined:
    Feb 6, 2015
    Posts:
    28
    Hihi, some feedback on v2.0 and NodeCanvas in general~

    1) The external inspector window is great! Not sure when you added it. =D The in-editor inspector has an oddity where you can click through the inspector scrollbar onto the canvas. This results in accidentally dragging nodes around while trying to scroll through a node's actions/conditions. Mouse wheel scrolling works well but my mouse wheel is broken in one direction.
    2) Is it possible to create local graphs for nested FSMs/BTs? Users might still need to reference scene objects in nested logic.
    3) NodeCanvas doesn't seem to work in WebGL builds.
    4) TIL you can copy tasks (including conditions) by right clicking their name in the inspector. You can paste by right clicking "Add Condition Task" and choosing Paste at the bottom of the list. This even works between FSMs and BTs. IS THIS NEW? It's so useful! You should document it, along with switching out of Dynamic Var by clearing the name string. Otherwise people can only stumble upon them by chance. xD;
    5) This isn't a bug but I was just curious as to why there is a three parameter limit for methods being called by the Execute Method action.

    Thanks for all your hard work and congrats on your release of 2.0! Seeing a NodeCanvas update makes my day.
     
  17. nuverian

    nuverian

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

    Thanks for your kind words :)

    1) The external inspector is there long time now. Yeah I forgot about the -click through the scrollbar- issue. I will see it fixed next time though.

    2) When graphs were game objects the great benefit they had was that they were there for you to add in prefabs, keep in scenes, or otherwise manipulate as you please etc. but on the other had a disadvantage they had was the same fact that they were gameobjects when they didnt REALY had to be apart from scene referencing and prefabing. To be honest that was a rather hard decision to take. So with that said :), currently there it's not possible to create local nested graphs, BUT,
    referencing scene objects in nested graphs is very easy through the blackboard variables since the Blackboard lives in the scene. It acts like a bridge.

    3) I havent tested WEBGL yet, but will do that.

    4) Oh, copy/pasting tasks this way is there long time now as well :) Yeah, there are so many things indeed that need some more exposition in the documentation. I will keep that in mind for the new docs im writing.

    5) Good question! The ExecuteFunction calls are wrapped into a generic class that wraps the delegate used to call the function as well as the type of the function parameters and return. Since I had to create a specific number of those eg: ReflectedAction<T1>, ReflectedAction<T1, T2>, ReflectedAction<T1, T2, T3>, I also placed a limit equal to the number of those. Take a look at folder "NodeCanvas/FrameWork/ReflectionWrappers" if you'd like.
    Supporting more parameters is very easy. All that is needed is to create a ReflectionAction<T1, T2, T3, T4> and a ReflectionFunction<TResult, T1, T2, T3, T4> for a 4th parameter :)

    Cheers and thanks a lot!
     
    Last edited: Mar 12, 2015
    iviachupichu likes this.
  18. RDeluxe

    RDeluxe

    Joined:
    Sep 29, 2013
    Posts:
    117
    Hi again,

    It seems that there is a small bug : I can't call a function with no parameters (it was working well in the previous version).
    When trying to bind MyFunction() (returning void) I got this error ;

    Code (CSharp):
    1. InvalidOperationException: not a generic type definition
    2. System.Type.MakeGenericType (System.Type[] typeArguments) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System/Type.cs:1210)
    3. ParadoxNotion.ReflectionTools.RTMakeGenericType (System.Type type, System.Type[] typeArgs) (at Assets/Extensions/NodeCanvas/_ParadoxNotion (shared)/Other/ReflectionTools.cs:309)
    4. NodeCanvas.Framework.Internal.ReflectedActionWrapper.Create (System.Reflection.MethodInfo method, IBlackboard bb) (at Assets/Extensions/NodeCanvas/Framework/ReflectionWrappers/ReflectedMethodWrapper.cs:42)
    5. NodeCanvas.Framework.Internal.ReflectedWrapper.Create (System.Reflection.MethodInfo method, IBlackboard bb) (at Assets/Extensions/NodeCanvas/Framework/ReflectionWrappers/ReflectedMethodWrapper.cs:20)
    6. NodeCanvas.Tasks.Actions.ExecuteFunction.<OnTaskInspectorGUI>m__174 (System.Reflection.MethodInfo method) (at Assets/Extensions/NodeCanvas/Tasks/Actions/ScriptControl/ExecuteFunction.cs:104)
    7. ParadoxNotion.Design.EditorUtils+<GetMethodSelectionMenu>c__AnonStoreyB9.<>m__192 (System.Object selectedMethod) (at Assets/Extensions/NodeCanvas/_ParadoxNotion (shared)/Design/PartialEditor/EditorUtils/EditorUtils_ContextMenus.cs:153)
    8. UnityEditor.GenericMenu.CatchMenu (System.Object userData, System.String[] options, Int32 selected) (at C:/buildslave/unity/build/artifacts/generated/common/editor/GenericMenu.gen.cs:120)
     
  19. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    Hello,
    Thats correct and spoted by @Unib0t as well.
    The issue is now fixed and will be inclued in the next hotfix release which I will submit today.
    If this is urgent for you, please PM me your email with invoice and I can send the fix to you now.

    Thanks!
     
  20. RDeluxe

    RDeluxe

    Joined:
    Sep 29, 2013
    Posts:
    117
    Ha, did not see @Unib0t comment.
    Thanks, I sent you a PM :)
     
  21. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    Fix PM send.
    Cheers!
     
  22. RDeluxe

    RDeluxe

    Joined:
    Sep 29, 2013
    Posts:
    117
    Hi again,

    It seems that I can't bind a SendEvent to a UIButton like before. I don't know if the "sealed" keyword can be responsible for this. Any reason for that ?

    Edit : Well, I guess it's not the sealed but more the fact that the function now takes a parameter that Unity, by default, can't handle (EventData).
     
    Last edited: Mar 13, 2015
  23. inas

    inas

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

    Is there any time estimation for Dialogue extension? So we can continue our project :)
     
    OnePxl likes this.
  24. Pajaroide

    Pajaroide

    Joined:
    Sep 19, 2012
    Posts:
    34
    Hi hi! Small feature suggestion :)

    Currently, when right-clicking on FSM conditions on the canvas, the text gets collapsed. I think it would be better for workflow if right-clicking a condition showed some of the same menus that right-clicking an action node does, for example: "copy assigned task" or "paste assigned task".

    In that same menu besides the "copy task" and "paste task" there could be a "collapse text" option in case someone needed the old functionality.

    Cheers! :D
     
    Last edited: Mar 13, 2015
    iviachupichu likes this.
  25. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    Hello everyone! So, I am submiting an update, mostly a hotfix and small feature request right now. Here are some details:

    • Fixed Local(binded) Graph handling:
      • Local graphs can now be stored in Owner prefab normaly.
      • Prefab overriding works normaly with local graphs.
      • Fixed duplicating a GraphOwner with a local graph no more references the same graph.
    • Fixed: ExecuteFunction Task with parametless function selected.
    • Fixed: Script Control Tasks now show the agent field for overriding, even before having a method selected.
    • Fixed deserialization error that shown in some cases and also added a serialization safety check.
    • The behaviour of a GraphOwner is now started OnStart rather than OnEnable for it's first time.
    • Fixed event based condition tasks that were returning true for 2 frames (instead of 1).
    • Fixed: Dragging a CanvasGroup now also drag other groups that are inside it.
    • Fixed WebPlayer builds.
    • Log Variable task now also logs the name of the variable.
    • Log Text task now shows a UI label at agent position (like it was before v2)
    • Added a SendEvent(string) override in GraphOwner to wrap the existing SendEvent(EventData)
    • Right Clicking connections now show a context menu (with copy/paste task if applicable, collapse/expand and delete) instead of default expand/collapse behaviour (this is probably the fastest feature request I've implemented :))

    Hello,
    I've just added an override SendEvent(string) so that you can once again use it like you did before.
    Cheers!

    Hey!
    Once the documentation is online again, I will wrap up and submit the DialogueTrees. So, I will submit it within this weekend :)

    Hey,
    Well, as you can see it's just added in this update submited :)



    Cheers and have fun!
     
    Last edited: Mar 13, 2015
    OnePxl, iviachupichu and Pajaroide like this.
  26. Pajaroide

    Pajaroide

    Joined:
    Sep 19, 2012
    Posts:
    34
    Man... Nuverian, you're awesome, thank you very much! :D !!
     
  27. iviachupichu

    iviachupichu

    Joined:
    Feb 6, 2015
    Posts:
    28
    Excellent update! Under three hours to implement a feature request there...

    This is incredibly minor but the NodeCanvas tab would look a bit nicer with an icon so that it's more consistent with the default window tabs. You can even reuse the little pawn/person icon that you attach to objects an FSM/BT on them.


    VS


    EDIT: The problem below was resolved by overriding OnOpenAsset.
    I recently purchased Script Inspector 2 to improve workflow on my laptop because MonoDevelop takes several minutes to load. It embeds a full code editor into the inspector (or a separate window). I'm trying to adjust NodeCanvas to open scripts in this interface rather than an external editor. The problem is that NodeCanvas' task interface uses run-time scripts while Script Inspector uses editor scripts.

    I was able to find this click-to-open functionality in EDITOR_Task.cs and its definition in EditorUtils.cs.
    Code (csharp):
    1. public static bool OpenScriptOfType(Type type){
    2. ......
    3.             AssetDatabase.OpenAsset(script);
    4. ......
    5. }
    Script Inspector has a class FGCodeWindow : EditorWindow with this static function.
    Code (csharp):
    1. public static void OpenAssetInTab(string guid)
    Because you cannot call an Editor script function from a runtime script it's not enough to simply change AssetDatabase.OpenAsset(script) into FGCodeWindow.OpenAssetInTab(AssetDatabase.AssetPathToGUID(path). Is there a way to work around this or are they inherently incompatible?
     
    Last edited: Mar 14, 2015
  28. nuverian

    nuverian

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

    Thanks for your kind words and sorry for late replies. I was sick for the last couple of days :/, but its all good now :)
    @iviachupichu ScriptInspector is a great plugin and you did well to get it. I am glad you resolved the issue.

    I'd also like to let everyone know that the DialogueTree extension module has been submited to the asset store team. It should be online soon. Sorry for the delay.

    Cheers!
     
    iviachupichu, OnePxl and Marble like this.
  29. inas

    inas

    Joined:
    Aug 2, 2013
    Posts:
    47
    @nuverian great!

    now if there are more tutorials and vids on NC... ;)
    (i know you are busy)
     
  30. nuverian

    nuverian

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

    The updated documentation is now online. Apart from the old now updated pages, there are also some new sections as well regarding Events, Generic Tasks, Data Binding and more.
    Furthermore all Behaviour Tree nodes now have a reference documentation as well.
    http://nodecanvas.com/documentation/

    Furthermore the requested API docs have been uploaded. You can find those here:
    http://nodecanvas.com/API/Docs/html/index.html


    Hello inas,

    I am realy focused on closing open cases related to NC 2 right now :) (like the docs I posted about) and the sample scenes which are not yet updated to v2.
    I really tried to cover everything important in the text documentation, as well as in the upcomming updated sample scenes.

    I am wondering whether you are after Behaviour Trees related tutorials or NC specific tutorials?
    Regarding Behaviour Trees there are a whole lot of tutorials available online and they realy transfer to NC as is, but if it's about NC specific, may I ask what sections you feel are uncovered or you'd like a tutorial about and will look into it when there is some more time :) ?
    Otherwise of course feel free to ask anything really :)

    Thanks a lot!
     
  31. inas

    inas

    Joined:
    Aug 2, 2013
    Posts:
    47
    Features are good, however tutorials and examples for NC will make higher adoption of NC. Beginner will get a gentle introduction, and advanced users will get one or two tips from you.

    I suggest to make tutorial on how to integrate NC on some genre of games. Or provide an easy to use examples or extension which cover common things like seek, patrol, cover, etc.

    Would love to see something like this from NC https://www.assetstore.unity3d.com/en/#!/content/16853 (it's Behavior Designer Movement Pack)
     
  32. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    Thanks for your suggestions inas.

    I really can't agree more, but it's hardly about the features right now, but rather the documentation that had to be updated and the whole NC 2 that just came along :)

    The new sample scenes I am working on are not just an updated version of the old ones, but rather completely new, and more game specific.

    Furthermore, I am actually working on an extension named "War Tactics". As you can tell by it's name it's about squad tactics, team leadership, covering, firing, injury etc. :)

    Some of the tasks in that linked pack are already included in NC. I can certainly add the rest.

    Cheers!
     
    OnePxl likes this.
  33. Pajaroide

    Pajaroide

    Joined:
    Sep 19, 2012
    Posts:
    34
    +1 for a "seek" and/or "wander" task via navmesh.
     
  34. Vectrex

    Vectrex

    Joined:
    Oct 31, 2009
    Posts:
    267
    Hey, just playing with State machines. I was wondering if it would be a good idea to have a list of actions as normal AND a second list of 'exit state' actions?
    eg the 'set visibility' action could turn the GO back off after turning one on on StateEnter.
    You could have overrides for this in each script, but often the exiting tasks can be different to the entering tasks. hmm

    Also can you highlight the outgoing arrows for selected states? (or darken everything else maybe).
    It might make it easier to read with lots of crossing wires.
     
  35. nuverian

    nuverian

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

    A seek task is already included in NC. It is just named "Move To Position" and "Move To GameObject". Here is a Wander task:
    Code (CSharp):
    1. using UnityEngine;
    2. using NodeCanvas.Framework;
    3. using ParadoxNotion.Design;
    4.  
    5. namespace NodeCanvas.Tasks.Actions{
    6.  
    7.     [Category("Movement")]
    8.     [Description("Makes the agent wander randomly within the navigation map")]
    9.     public class Wander : ActionTask<NavMeshAgent> {
    10.  
    11.         public BBParameter<float> speed = 4;
    12.         public BBParameter<float> stoppingDistance = 0.1f;
    13.         public BBParameter<float> minWanderDistance = 5;
    14.         public BBParameter<float> maxWanderDistance = 20;
    15.         public bool repeat = true;
    16.  
    17.         protected override string OnInit(){
    18.             if (!agent.isOnNavMesh)
    19.                 return "NavMeshAgent is not enabled or on the NavMesh";
    20.             agent.speed = speed.value;
    21.             agent.stoppingDistance = stoppingDistance.value;
    22.             return null;
    23.         }
    24.  
    25.         protected override void OnExecute(){ DoWander(); }
    26.         protected override void OnUpdate(){
    27.             if (!agent.pathPending && agent.remainingDistance <= agent.stoppingDistance){
    28.                 if (repeat){
    29.                     DoWander();
    30.                 } else {
    31.                     EndAction();
    32.                 }
    33.             }
    34.         }
    35.  
    36.         void DoWander(){
    37.             minWanderDistance.value = Mathf.Min(minWanderDistance.value, maxWanderDistance.value);
    38.             var wanderPos = Random.insideUnitSphere * maxWanderDistance.value;
    39.             while ( (wanderPos - agent.transform.position).sqrMagnitude < minWanderDistance.value )
    40.                 wanderPos = Random.insideUnitSphere * maxWanderDistance.value;
    41.  
    42.             agent.SetDestination(wanderPos);
    43.         }
    44.  
    45.         protected override void OnStop(){
    46.             if (agent.isOnNavMesh)
    47.                 agent.ResetPath();
    48.         }
    49.  
    50.         protected override void OnPause(){ OnStop(); }
    51.     }
    52. }
    Hey Vectrex,

    I've been asked before by other people about OnExit actions. Apart from the fact that this will be (in my opinion) way too confusing, it's also not realy possible. The reason being that if OnExit, you add an action that takes time to complete, then when you enter the other state, you will be having both OnExit actions of previous state still running and OnEnter actions of the new state running as well. This might lead up to having a big trail of still running OnExit actions while also being possible to return to those state having that trail and things get funky (apart from confusing ). It can become like snake eating it's tail.
    Sorry, but I really dont see it comming :).

    Sure I can take a look at somehow highlighting outgoing connections.

    Cheers!
     
    Last edited: Mar 17, 2015
    Pajaroide likes this.
  36. iviachupichu

    iviachupichu

    Joined:
    Feb 6, 2015
    Posts:
    28
    Video tutorials are a bit of a luxury, though they can definitely push sales. Behavior Designer has done a great job providing videos and custom actions for other assets. I occasionally use them as reference while designing behavior trees in NodeCanvas, as the concepts transfer pretty easily. With that said, you can find references for state machines and behavior trees pretty easily on the internet. For any NodeCanvas-specific issues the documentation is thorough enough. Between spending time making videos of concepts that aren't really specific to NodeCanvas and improving NodeCanvas itself, I'd actually favor the latter.

    Of course, having more resources and reference never hurts. If there's significant interest in videos then perhaps we can start a community effort to make some for NodeCanvas.


    Another minor aesthetic detail:

    Word wrapping kinda sucks for certain node names.


    In documentation the JSON Export/Import is missing links to the previous/next pages at the bottom.


    Is it intended that you cannot create nested local graphs? It seems pretty necessary to make prefabs completely "self-contained". In the mean time, here's a work-around:
    1) Add this method to NodeCanvas/Design/PartialEditor/EDITOR_Node.cs.
    Code (csharp):
    1.     //Helper function to create a local nested graph for a IGraphAssignable
    2.      protected static void CreateNestedLocal<T>(IGraphAssignable parent) where T:Graph{
    3.  
    4.        var newGraph = ScriptableObject.CreateInstance<T>();
    5.        if (newGraph != null){
    6.          Undo.RegisterCreatedObjectUndo(newGraph, "CreateNested");
    7.          parent.nestedGraph = newGraph;
    8.          EditorUtility.SetDirty(newGraph);
    9.        }
    10.      }
    2) Find (optional: duplicate and rename class) the relevant nodes in:
    NodeCanvas/Modules/BehaviorTrees/Leafs (NestedFSM/SubTree)
    NodeCanvas/Modules/StateMachines/Nodes (NestedFSMState/NestedBTState)
    3) Under the OnNodeGUI method, change:
    Code (csharp):
    1. Node.CreateNested<BehaviourTree>(this);
    to​
    Code (csharp):
    1. Node.CreateNestedLocal<BehaviourTree>(this);
    You can also just change the CreateNested method within EDITOR_Node.cs outright, but creating a separate CreateNestedLocal method and separate nodes is less destructive. Also feel free to remove the surrounding if statement (with the CREATE NEW) button for local graph nodes as it's no longer necessary.
     
    Last edited: Mar 17, 2015
  37. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087

    Hey,

    I really appreciate the community effort motion :)
    I hope that the new sample scenes will cover for the tutorials, and that I had more time available to do everything I really want to do :)


    Regarding the word wrapping is my bad and related to the indie (light) theme skin. Please find 'NodeCanvasSkinLight' and remove WordWrap option from the Label Style. (recompile or enter/exit playmode to take effect)

    I think that SubGraphs should be assets and that is basicaly because of the fact that I believe that SubGraphs are ment to be reusable as self-contained behaviours.
    Practicaly the thing that I think is that you possibly don't like, is the inability to assign scene object references (or prefab hierarchy ones) directly in the graph.
    But a realy nice way to do so, is using Blackboard Variables. Since the Blackboard is part of the GraphOwner (and thus possibly the prefab) and the Blackboard variables are propagated to all SubGraphs, you are free to assign scene object references to variables and use those variables in the SubGraphs in form of Parameters (instead of direct references).

    By the way, the workaround you suggest, unfortunately wont really work when it comes to prefabs, because the ScriptableObject instantiated will not persist in the prefab since it's saved in the scene and thus it is a scene reference. There are of course ways to make this happen, but it's a bit more complex than that :)

    (PS: Thanks, I've added previous/next links to that page now)
     
    iviachupichu likes this.
  38. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    Version 2.1 is now live on the asset store.
    As usual, the change log can be found here.
     
    iviachupichu likes this.
  39. iviachupichu

    iviachupichu

    Joined:
    Feb 6, 2015
    Posts:
    28
    You actually solved the scene reference problem for me earlier. =D

    It just seems a bit unnecessary to create a separate asset file for certain uses. For example, using a nested behavior tree to simulate a complex switch inside an FSM is very specific to that FSM. I do see your point about reusability but I don't think it should be strictly enforced. Even if you used nested trees for Idle, Scout, Fight, Free, etc... behaviors and it makes sense to reuse them, it's still overkill to create four extra files if you aren't going to reuse them. JSON export or copy/paste can be used to transfer the logic to a separate asset file anywhere down the line if necessary.

    It makes a lot of sense to use nested trees/states for reusable logic, but sometimes you just want to condense 10 nodes into 1 and a nested FSM is the way to do it.

    Example:


    Use Skill

    Assuming this was the entire logic for an enemy turn, it makes perfect sense to keep the outside FSM as an asset file (though even that isn't necessay) but the nested FSM is only there for organizational purposes and there's no reason to force it into a separate file imo.

    The wiring is also a little scary considering it's symmetrical in the same direction the arrows leave the node. Does moving the transition exit points to the center (instead of the bottom) not look good? I assume you've tried it already since your design skills are pretty spot-on.
     
  40. Nakor

    Nakor

    Joined:
    Sep 5, 2012
    Posts:
    31
    Hello,

    I hate to be a beggar but I own probably all of the other visual scripting tools and I find that after not too long I grow tired of having to follow some odd format for scripts every time I want to write an Action or whatever and I end up just writing my own code and ignoring the visual scripting tool. I realize how much these tools can help, but as a one man team with strong programming capabilites, I'm wondering if it is worth my while. It looks like you have done a great job with it. What I am wondering is, is there some sort of a demo version that I could test out? It's ok if it is very limited. If not I will probably end up buying it anyway lol. I'm a sucker for this type of thing.
     
  41. Vectrex

    Vectrex

    Joined:
    Oct 31, 2009
    Posts:
    267
  42. Vectrex

    Vectrex

    Joined:
    Oct 31, 2009
    Posts:
    267
    NC uses reflection to let you interact with external code with no requirements. See the 'script control' bits.
    You can still use his interfaces if you want it slightly more embedded in the NC editor, but I don't bother much.
     
  43. nuverian

    nuverian

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

    Well, I kind of agre in some of your points, thus I will really take a look at the ability to create local nested graphs in the future :)

    Regarding the wiring, I have indeed tried a lot of things (for FSMs) and as it stands currently the states are not really ment to be placed aligned one after another but rather in a more diagonal "formation". Its a realy tricky situation, especialy for not overlaping transitions. Moving the exit arrows to the center doesnt really have much of a difference though, unless I misunderstood what you mean of course :)

    Thanks!

    Hello there,
    It's totaly understandable, but unfortunately there is currently no trial version and will require some time to build one, else I would have certainly send you one right now
    Like @Vectrex said, while you can, you don't really have to follow NodeCanvas way of thinking and "format". Instead you can work with your coding skill, writing scripts as you please and use NC to "interface" with them at a higher level.
    In other words, it's really design around the premise that "you dont have to work for it, it has to work for you" :)

    But let me know if you have any questions.
    Cheers!

    Hey,
    I am glad they get smaller :)
    Nice nasty bug find. Thanks. I have just fixed this now. PMing you the fix as well.

    I opted for plain string names for events so that it's easier to use for example from code (SendEvent(string name)), instead of having to get the defined events from some place and then choosing and sending that one. It's quite more flexible this way considering it's not only an editor thing.

    Yeah, I can add an "Add More Types" entry there, although once you do know about the Prefered Types Editor, its not realy useful anymore :)

    I am looking at ways to bind variables to other GOs, although I realy dont like it to be honest (workflow wise) :)

    Your other nots have been taken care of.

    Cheers!
     
    iviachupichu likes this.
  44. Unib0t

    Unib0t

    Joined:
    Jan 4, 2013
    Posts:
    15
    Is it possible within an FSM to force a state on another FSM? Meaning regardless of the current state in the target FSM, the source FSM would force it to jump to a particular state. What would be the best way to accomplish this?
     
  45. nuverian

    nuverian

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

    Yes its quite possible. If I understood you correclty, this action will do what you want:
    Code (CSharp):
    1. using ParadoxNotion.Design;
    2. using NodeCanvas.Framework;
    3. using NodeCanvas.StateMachines;
    4.  
    5. namespace NodeCanvas.Tasks.Actions{
    6.  
    7.     //[Category("some category you like :) ")]
    8.     public class TriggerState : ActionTask<FSMOwner>{
    9.  
    10.         [RequiredField]
    11.         public BBParameter<string> stateName;
    12.  
    13.         protected override string info{
    14.             get {return string.Format("Trigger {0} State", stateName.ToString());}
    15.         }
    16.  
    17.         protected override void OnExecute(){
    18.             agent.TriggerState(stateName.value);
    19.             EndAction();
    20.         }
    21.     }
    22. }
    Remember that to trigger the state of another FSMOwner's fsm, you should overide the agent and select that other FSMOwner.

    Let me know if thats what you are after.
    Cheers!
     
  46. Unib0t

    Unib0t

    Joined:
    Jan 4, 2013
    Posts:
    15
    Yes thanks.... but I just realized that I missed the whole API section :p

    You might want to make it a bit more conspicuous, as the links I've followed for "Documentation" from the asset store and your site take you directly to the documentation page, while the API link is hidden in the "Documentation" tab which I never clicked as I assumed it would take me to the documentation page I was already reading :)
     
  47. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    Heh :)
    I can probably rename API to "Coding API" and add a link in the documentation as well.

    Thanks for noting :_)
     
  48. Vectrex

    Vectrex

    Joined:
    Oct 31, 2009
    Posts:
    267
    Oh, yeah you can still use strings and type them in. I was thinking that if you already typed some in, you'd also have a pulldown to select from. So if you typed a different one, it'd create a new event.

    With FSM exit actions: How would I do that? Do actions have an override that runs when they, 'OnDisable' type thing?
    Also you say you don't want to do this because previous States might still be running. Doesn't that break the rules of a statemachine? I'm not an expert, but that seems like it could be really messy.
     
  49. nuverian

    nuverian

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

    Yes, you can override "OnStop" in ActionTasks for that.
    So we agree that its not a good thing to have actions begin running OnExit of a state (which yes, kind of break the rules). :)

    Cheers!
     
  50. Unib0t

    Unib0t

    Joined:
    Jan 4, 2013
    Posts:
    15
    @nuverian Is there any performance penalty when calling our own methods via a script control task, vs moving the same logic into a custom task? Of course for a one-time execution it would be negligible, but say for something that is called repeatedly on update?