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,
    Can you please clarify what you mean by GA? :)
     
  2. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    The new version is live on the Asset Store. To recap the changes:

    • Great performance and GC improve due to the way actions were executed (rewriten).
    • Added "Duplicate Branch" in composite node context menu.
    • Added option to "Automatic Branch Move" without the need to hold down SHIFT.
    • Fixed Execute Function script control task in which Coroutine functions were not working properly.
    • Fixed WPA and iOS errors that were kicking in some cases.
    Cheers!
     
  3. desyashasyi

    desyashasyi

    Joined:
    Nov 22, 2012
    Posts:
    73
    Hi Nuverian, I am sorry that I did not make it clear. GA is Genetic Algorithm. Thanks.
     
  4. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    Ah, thanks for the clarification. Can you please specify what do you mean though by embedding in NodeCanvas? In what form? :)

    Thanks
     
  5. Dbone

    Dbone

    Joined:
    Mar 10, 2014
    Posts:
    56
    Hi Nuverian,

    I'm having a problem with the visual debugging since I updated to 1.59w. The debugging gets stuck showing green on one node at a time, often not even showing an actual active node. The graphs do work as expected though.
    To do the update I deleted the nodecanvas folder and re-installed from the asset store.

    Thoughts?
     
  6. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    Hello,
    There is a very bad bug I managed to put into the latest version accidentaly.
    I'm already submiting the next version.

    @Everyone : Please PM me an email and invoice number and I will immediately send you the new version! Current version on the asset store has a nasty bug

    Thanks. Mistakes do happen :)
     
  7. desyashasyi

    desyashasyi

    Joined:
    Nov 22, 2012
    Posts:
    73
    Hii Nuverian,
    Thank you for the reply. I have task to optimize my NPCs' using Genetic Algorithm. I want to embed this algorithm to NC so, i can evolve the NPC behavior. I have attached a paper, hope it will explain the intention clearly :).
     

    Attached Files:

  8. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    Hey desyashasyi,
    I took a look a the paper, but to be honest it's a whole different system behind and is well beyond the scope of NC, Behaviour Trees or FSMs :)
    It's a field that to be honest I can't really help a lot, but I can certainly provide help in more specific implementation questions that you may have.

    Cheers!
     
  9. desyashasyi

    desyashasyi

    Joined:
    Nov 22, 2012
    Posts:
    73
    Hii Nuverian,
    I see :-D. Thanks a alot. However, I have difficulty to code serialize custom list that contain game object.

    I have a custom list contain name(string), model(GameOBject) and sprite(string).
    and here is my costum list code:

    Code (CSharp):
    1. using System;
    2. using NodeCanvas.Variables;
    3. using UnityEngine;
    4.  
    5. namespace NodeCanvas.Magnitude{
    6.     [Serializable]
    7.     public class NPCActorList{
    8.         public string name;
    9.         public GameObject model;
    10.         public string sprite;
    11.     }
    12.     [Serializable]
    13.     public class BBActorList : BBListVariable<NPCActorList> { }
    14. }
    Code (CSharp):
    1. using NodeCanvas.Variables;
    2.  
    3. namespace NodeCanvas.Magnitude{
    4.     [AddComponentMenu("Magnitude")]
    5.     public class NPCActorListData : VariableData{
    6.  
    7.         public List<NPCActorList> value = new List<NPCActorList>();
    8.  
    9.         public override object objectValue{
    10.             get {return value;}
    11.             set
    12.             {
    13.                 if (this.value != (List<NPCActorList>)value ){
    14.                     this.value = (List<NPCActorList>)value;
    15.                     OnValueChanged(value);
    16.                 }
    17.             }
    18.         }
    19.  
    20.         public override object GetSerialized(){
    21.        
    22.             var goPaths = new List<string>();
    23.             foreach (NPCActorList go in value){
    24.            
    25.                 var obj = go.model;
    26.                 if (obj == null){
    27.                     goPaths.Add(null);
    28.                     continue;
    29.                 }
    30.            
    31.                 string path= "/" + obj.name;
    32.            
    33.                 while (obj.transform.parent != null){
    34.                     obj = obj.transform.parent.gameObject;
    35.                     path = "/" + obj.name + path;
    36.                 }
    37.            
    38.                 goPaths.Add(path);
    39.             }
    40.        
    41.             return goPaths;
    42.         }
    43.  
    44. ----->>> How to set serialized list?
    45.  
    46.     }
    47. }
    48.  
     
    Last edited: Dec 24, 2014
  10. nuverian

    nuverian

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

    Doing this is only usefull when you are using the Save/Load feature of the Blackboard. If you are not, you can simply do this for your convenience:

    Code (CSharp):
    1. using NodeCanvas.Variables;
    2. namespace NodeCanvas.Magnitude{
    3.     public class NPCActorListData : VariableData{
    4.         public List<NPCActorList> value = new List<NPCActorList>();
    5.     }
    6. }
    7.  
     
  11. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    I've very glad to say that NodeCanvas version 1.6 is submited and soon live on the asset store. With this update, the 50% christmas sale is also droped

    Most importantely this version fixes the buged version 1.5.9w that is currently on the store. If you are using the current version please send me an email at info@nodecanvas.com along with your invoice ID and I will send you latest version 1.6 ASAP.

    As with every 1.x NC release, there are some big changes:

    Core Changes
    • NodeCanvas no more creates game objects for nodes. All your previously created graphs are updated seamlesly.
    • Action Task execution has been totaly refactored to be much faster and minimize GC allocations down to zero, which were caused by the rapid registering/unregister in the MonoManager singleton.
    • Variables has been totaly refactored to use generics thus also be much faster and minimize GC allocations down to zero, that were caused due to value boxing.
    • A lot of other similar neatpicking optimizations for increased performance and zero GC allocations.
    • Prefab Editing is now possible, so it's now far more convenient when you want to edit a prefab SubTree since you can do it directly without the need to place it in the scene or lose track of the behaviour hierarchy when navigating graphs and subgraphs within the editor.
    New Variable-Property Binding
    While long time now, there is the ability to bind a blackboard variable to a component property, this was previously done using an extra Component (Blackboard Property Binder). This didn't have the exact instant readability effect that NC is about though. As a result, in version 1.6 blackboard variables can directly be binded to any property from within the blackboard GUI.

    Binder.png
    "MyVector3" variable is binded to Transform.position property

    The benefits of this new way of doing this are the following:
    • It is instantely readable with which property the variable is binded within the editor.
    • It is more streamlined and thus becomes more part of the workflow.
    • It is much faster than having a seperate component syncing the property, since the property will be get/set only when you get/set the variable instead of in an update.
    • It's also faster since it doesn't use reflection invokes in runtime, but rather a simple delegate call.
    • You can use variables as a direct 'bridge' to code.
    Using variable-property binding like this opens up a whole lot of possibilities since you can keep your behaviour tree even more focused on the actual behaviour and not on doing variables math, which a behaviour tree is not about. Thus the designer can focus on design and the programmer on programming.

    BT Priority Selector
    The new Priority Selector node added, works similar to a normal Selector, but the child nodes are ticked in order of their priority. Priority values are specified within the Priority Selector and shown on top of the connections for readability. Priority values are simple floats that can of course be assigned from a Blackboard variable. Obviously that variable could optionaly be binded to a component float property like described above.

    PrioritySelector.png
    FSM "Repeat State" Option
    The FSM Action State now has an option to Repeat State Actions. When all actions of the state list have been completed, the actions will repeat. As a result, such a state is never Finished.

    Repeat.png
    Custom Variables Data API Change
    Due to the change of how variable data are now defined using generics, it's now far easier to create a custom blackboard variable. For example:
    public class RectData : VariableData<Rect>{}
    public class BBRect : BBVariable<Rect>{}

    Blackboards Convenience

    Working with blackboards is now more convenient. Specificaly:
    • Duplicate variables names in a blackboard are now shown in red.
    • Duplicate global blackboard naming is now also shown in red.
    BB.png

    Once again, if you want version 1.6 now, please send a request with your invoice ID at info@nodecanvas.com.
    Please bare in mind that the current live version on the asset store 1.5.9w is buggy.

    Happy holidays and have fun.
    Gavalakis Vaggelis
     
    hopeful, inas and elbows like this.
  12. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,649
    Wish you the best. Thanks for the release. ;)
     
  13. Frenchgui

    Frenchgui

    Joined:
    Jan 3, 2015
    Posts:
    1
    Hi! I'm very happy with NodeCanevas. Just wish a (very) little improvement with actions lists, the delete
    action icon is not always reachable. ;)
    BT_image.jpg
     
  14. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    Hello,
    I'm glad you enjoy using NC :)
    Sure. I will fix the issue in the next version. Thanks for reminding me.

    Cheers!
     
  15. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    The new version 1.6 is finaly live on the asset store.
    You can read about the changes just a couple of posts above.

    Happy new year!
    Gavalakis Vaggelis
     
    elbows likes this.
  16. landon912

    landon912

    Joined:
    Nov 8, 2011
    Posts:
    1,579
    Thank you.
     
  17. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    Hello everyone. Version 1.6.1 is now submited and pending review. Here are the changes:

    • Added missing BT Priority Selector.
    • Opitmized Unity's messages forwarding to Tasks.
    • AgentUtilities is now a partial class so you can easilty add your custom messages to be handled if you do send messages to agents. (for example if you are using ULink)
    • Blackboard variable's binding is now saved & loaded when saving/loading the blackboard. The binded property itslef (if any) is also set to the value it was saved. In other words, binded property values can be persistant between game sessions, like the variables are.
    • Removed the "Shortcut" option from the connections.
    • Added GoTo node in DialogueTree to replace the connection Shortcut option.
    • Fixed Implemented Action Task error.
    • Fixed long task summary info displaying in action/condition lists, which made the "X" button disapear.
    • Fixed Blackboard.SetDataValue for when setting a base type variable with a derived type value.

    Cheers!
     
    inas likes this.
  18. inas

    inas

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

    Your progress on feature wise is really awesome. To make it better, is there anyone who work on tutorial or example for NC? havent seen any new vids or tutorials for NC
     
  19. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    Thanks inas :)
    Please let me know what is that you would like to see covered so that I do just that for when I create some tutorials..
    Thanks


    As a sidenote, the new version is also live on the asset store.
     
  20. inas

    inas

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

    I think tutorial or vids on how we can use NC across different genre of game will be helpful to promote NC on new users. The genre could be anything like FPS, Hack and slash, RPG, or even Adventure type game (with dialogues)
     
  21. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    Alright then. I'll take that into account for the upcomming tutorials/examples :)
    Thanks for your input
     
  22. Danirey

    Danirey

    Joined:
    Apr 3, 2013
    Posts:
    548
    Hi!

    I'm getting a weird problem when checking if a gameobject stored in a variable in the main script of the agent is null. I'm using check field. It is a simple check for a key down and the variable is not null. With that i don't need to exit the current state. Obvious... :p
    t works when i play. The first time i press the key, and nothing happens because the variable checked is null. All right, but i fill that variable and try again. it enters the state as it should, and on exit it clears the variable to begin again. The probkem is that after the firs time i fill the variable, it will enter that state no matter the variable. I check the variable and it is in fact null, so it should not enter the state. I decided then make a check in my custom action task simply comparing that variable with null, en if it is null then EndAction(true). But by some force of the universe, the action doesn't end. I have to put a return; if it is OnExecute or a return true; if it is a Coroutine.... Here is the code. Any idea?

    Thanks :)

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using NodeCanvas;
    4. using NodeCanvas.Variables;
    5.  
    6. [Category("Jagged")]
    7.  
    8. public class SWAP_THROW_WEAPON : ActionTask
    9. {
    10.         private PLAYER playerBase;
    11.         private Animator anim;
    12.         public bool throwWeapon = false;
    13.        
    14.         protected override void OnExecute ()
    15.         {
    16.                 playerBase = agent.GetComponent<PLAYER> ();//get a reference to the base player script
    17.                 if (playerBase.weaponSelected == null) {//if it is no weapon selected get out!!!!
    18.                         EndAction (true);
    19.                         Debug.Log ("Should be terminated and  get out of the state.");
    20.                         return;
    21.                         //return true;
    22.                 }
    23.                 anim = agent.GetComponent<Animator> ();//get a reference to the animator component
    24.                 StartCoroutine (swap ());
    25.         }
    26.        
    27.         IEnumerator swap ()
    28.         {...
    29. ...
     
  23. Danirey

    Danirey

    Joined:
    Apr 3, 2013
    Posts:
    548
    Here is a graph capture:

    pic.png


    Whit this graph and the "weaponSelected var==null" it will enter the state anyway after the first time.
     
  24. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    @Danirey
    I just did a test with CheckField == null and works as expected. There was an issue with it in some previous NC version. Are you using a 1.6.x version?

    2015-01-16_20h35_52.png
    Regarding your custom action I am not sure what's the problem :) . Naturaly, when you call EndAction, the method will continue. It's not (cant) be stoped in the middle. In your example, you do need to 'return' or put the rest of the code in an 'else'. The same applies within a coroutine but remember that the coresponding 'return' within a coroutine is 'yield break'.
    Is there a reason why you don't override and use OnUpdate? Furthermore you can initialize the components in OnInit for performance. Here is what I overal suggest:

    Code (CSharp):
    1. public class SWAP_THROW_WEAPON : ActionTask{
    2.    
    3.     private PLAYER playerBase;
    4.     private Animator anim;
    5.     public bool throwWeapon = false;
    6.  
    7.     //init and error check
    8.     protected override string OnInit(){
    9.         playerBase = agent.GetComponent<PLAYER>();
    10.         anim = agent.GetComponent<Animator>();
    11.         if (playerBase == null || anim == null)
    12.             return ("No PLAYER and Animator components found on agent");
    13.         return null; //no error
    14.     }
    15.  
    16.     protected override void OnExecute(){
    17.         if (playerBase.weaponSelected == null){
    18.             EndAction();
    19.         }
    20.     }
    21.  
    22.     protected override void OnUpdate(){
    23.         //Do swap
    24.         if (/* Some condition that shows the swap is complete */){
    25.             EndAction();
    26.         }
    27.     }
    28. }

    OnUpdate is called per frame while the action is running, which means from when the action is executed and until EndAction is called.
     
  25. Danirey

    Danirey

    Joined:
    Apr 3, 2013
    Posts:
    548
    Thanks nuverian

    Ahh.... I didn't know about the EndAction thing... Thanks.

    Right, i will use onInit from now on...

    I can't use OnUpdate in this particular case, because i need to pause the actions to wait for animations, and in Update i can't do that, right?

    The main thing is the condition problem. I'm using 1.6.0 right now.

    I've tried several times and the condition is very simple, so this can't be a scripting problem i think/hope. I double check every time the variable content and it is always null, but after the first access in the state, it will enter again and again no matter the variable is null or not.
     
    Last edited: Jan 16, 2015
  26. desyashasyi

    desyashasyi

    Joined:
    Nov 22, 2012
    Posts:
    73
    Hi Nuverian,
    I want to replace StarGraphOwner Script so i can fill the GraphOwner Variable with GameObject Variable. I want to add the graph owner at runtime (by Finding GameObject that contain NC Behavior Tree). Which part of StartGraphOwner should I change? Thanks.

    NC.png


    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using HutongGames.PlayMaker;
    4. using NodeCanvas;
    5.  
    6. [ActionCategory("NodeCanvas")]
    7. [HutongGames.PlayMaker.Tooltip("Execute a graph already assigned to an owner")]
    8. public class StartOwnerGraph : PlayMakerActions {
    9.  
    10.     [HutongGames.PlayMaker.RequiredField]
    11.     [HutongGames.PlayMaker.Tooltip("The GraphOwner to execute")]
    12.     public GraphOwner graphOwner;
    13.  
    14.     [HutongGames.PlayMaker.Tooltip("If true, this FSM Variables will be copied to the blackboard")]
    15.     public bool syncVariables;
    16.  
    17.     [HutongGames.PlayMaker.Tooltip("Possible only if 'Run Forever' is set to false, or somehow the graph ends")]
    18.     public FsmEvent finishEvent;
    19.  
    20.     [UIHint(UIHint.Description)]
    21.     public string desc = "Will start an Owner Graph. Sync Variables will sync supported PlayMaker Variables with Owner's Blackboard variables.";
    22.  
    23.     public override void Reset(){
    24.         graphOwner = null;
    25.         syncVariables = true;
    26.     }
    27.  
    28.     public override void OnEnter(){
    29.  
    30.         if (syncVariables && graphOwner.blackboard != null)
    31.             SyncToNC(graphOwner.blackboard);
    32.  
    33.         graphOwner.StartBehaviour(OnGraphFinished);
    34.     }
    35.  
    36.     public override void OnUpdate(){
    37.      
    38.         if (syncVariables && graphOwner != null)
    39.             SyncToPlayMaker(graphOwner.blackboard);
    40.     }
    41.  
    42.     void OnGraphFinished(){
    43.  
    44.         Finish();
    45.         Fsm.Event(finishEvent);
    46.     }
    47.  
    48.     public override void OnExit(){
    49.  
    50.         graphOwner.StopBehaviour();
    51.         if (syncVariables && graphOwner.blackboard != null)
    52.             SyncToPlayMaker(graphOwner.blackboard);
    53.     }
    54. }
     
  27. desyashasyi

    desyashasyi

    Joined:
    Nov 22, 2012
    Posts:
    73
    I solved my problems.
     
    Last edited: Jan 18, 2015
  28. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    Sorry for the late reply.
    Is it at all possible to send a small project reproducing this issue please, as I can't seem to reproduce it myself.
    Thanks a lot!

    Hello,
    I am glad you figured it out. Let me know if there is anything else at all :)
    Also, I would suggest creating a seperate action for this so that when you update you don't lose the changes by accident.

    Cheers!
     
  29. desyashasyi

    desyashasyi

    Joined:
    Nov 22, 2012
    Posts:
    73
    Hi Nuverian,
    Thank you. Now I have another problem. Even though using original StarOwnerGraph task/action, The OnFinishGraph state is not work. As you can see in the video, the action of StartOwnerGraph still active even though NodeCanvas graph was executed. What is the problem?

     
  30. Danirey

    Danirey

    Joined:
    Apr 3, 2013
    Posts:
    548
    Hi,
    don't worry. I can't reproduce it either outside of the current scene. I've created a new empty state with the same condition, and it works fine always. That means the problem could be in the content of the state. So i've decided recheck the code, and can't find anything that leaves the weaponSelected occupied. I've created a test bool to use in the IN condition. I check in the update of the player's main script if weaponSelected is null and set the bool to true or false. In nodecanvas, i use the same field check but now with the bool and not the GameObject. It works perfect. So i can't understand why with the gameObject var check it wont work.... I've attached the full script i use for the custom task inside this state. Remember i'm still trying to convert all this from JS to C and still learning, so don't kill me after looking at it... :p

    Let me know. And thanks!
     

    Attached Files:

  31. WizardGameDev

    WizardGameDev

    Joined:
    Jul 25, 2012
    Posts:
    62
    Jumping in here to just say this is a most amazing asset. The built in FSM work is great as well as the ability to directly use playmaker FSM's which has such broad support and tons of actions.

    So I'm wanting to work with the Unity 4.6 UI. Specifically set/bind input boxes in the UI based on strings in the blackboard. It would be really nice to have two way... where if the user changes the text box we have an easy way to get that change and store it and if the data changes from the state machine, it would update in the UI.

    If there was a clean UI layer for nodecanvas that uses the new 4.6 gui that would be a huge help. Maybe I'm missing something easy but right it seems like it would be a big pain to simply read a record out of a SQL database and populate a set of fields on a form. One big step toward getting there with tools like Nodecanvas and Playmaker is having a reasonably easy way to do two way event binding.

    Any ideas on how to accomplish something like that? I don't need it to be easy... just need a direction. A set of actions that could easily help communicate with the new UI tools along with some tutorials on how to make it work would be good timing now for an asset like this.
     
  32. username132323232

    username132323232

    Joined:
    Dec 9, 2014
    Posts:
    477
    I purchased NodeCanvas mostly for its powerful FSM. Could you recommend a step-by-step tutorial on setting up a simple FSM and hooking it up to an existing game written in C#? A video would be great.
     
  33. nuverian

    nuverian

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

    When you are starting a behaviour graph from within Playmaker like you do, it's best if you don't also start it OnEnable.
    The problem you are having is because on the BehaviourTreeOwner inspector you have set the behaviour to "Start Behaviour" OnEnable. As such, when PlayMaker is trying to start that same behaviour you get a warning message saying "The Graph is already active". Thus Playmaker does not receive the callback for when the graph is finished since it never started it.
    In other words, all you have to do is to set "OnEnable" on the BehaviourTreeOwner inspector to "Do Nothing".
    You will probably also want to set the OnDisable to DoNothing if you want to control the behaviour from within Playmaker.

    I will try and make this easier in the next update.

    Thanks!

    Hey,

    I really think that there is something going on in your coroutine. Notice that if you have a codition in the transition from THROW_ITEM to IDLE (which as far as I can see you do), the coroutine will not stop execution automaticaly. As such, and most probably, due to the WaitForSeconds the 'weaponSelected' may still not be null when you recheck the transition from IDLE to THROW_ITEM. I can't really tell fom sure by just looking at your action as it is quite complex, but the coroutine might be a potential problem to this, worth to re-check.
    I am sorry I can't help more in this, but it's quite hard just by looking at the action code :/

    Hello and thanks a lot! I appreciate it :)
    There are some actions already included for the new Unity GUI, but moslty irelevant to what you are after. To get/set input UI fields or anything really, you can use the ScriptControl 'GetProperty' and 'SetProperty' tasks. Now that is not exactly a binding of course. So, the best way to achieve what you are after, is to use the new 'Variable Binding' feature, where you can bind a Blackboard variable with a property. This is done with the small button on the far right on the variable.
    This allows you to bind a Variable's value to a property's value on any Component on the same game object as the blackboard, which are of course of the same type. Then whenever you get or set the variable's value you will get or set the binded property's value :)
    Since most probably the Text UI element will not be on the same game object as the blackboard will be, you can create an intermediate MonoBehaviour to help with your binding. Here is an example:

    - Create a super simple MonoBehaviour to hold the references of the UI elements you want to bind and create the respective properties.
    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.UI;
    3.  
    4. public class GUIBinders : MonoBehaviour {
    5.  
    6.     public Text inputText;
    7.  
    8.     public string InputTextValue{
    9.         get {return inputText.text;}
    10.         set {inputText.text = value;}
    11.     }
    12. }
    - Add this script on the same game object as the blackboard and using the small button on the far right, bind the variable (string variable in this case) with the GUIBinder's InputTextValue property.

    2015-01-20_00h02_49.png

    So, from now on the "nameInput" named variable will always reflect the UI.Text value.

    Let me know if that is something that satisfies what you are after :)

    Cheers!


    Hello and thanks a lot :)
    Unfortunately there is no video at the moment, but generaly speaking the core workflow of hooking it on top of your existing code is the use of the Script Control Tasks as well as the Variable Binding described just above. Alternatively you can of course create custom Tasks to wrap existing functionality of your project into small re-usable behaviours.
    Creating an FSM is a simple task of adding the FSMOwner Component on the game object you want to control with an FSM and hit "Create New FSM" on that inspector.
    Please let me know a bit more specificaly of the topic you are after and I will be very glad to answer all your qeustions in as much detail as I can.

    Thanks!
     
    Last edited: Jan 19, 2015
  34. username132323232

    username132323232

    Joined:
    Dec 9, 2014
    Posts:
    477
    Sounds good. Great job on the asset! It's actually fun to "play" with and to discover all the cool features! I will probably have more questions soon, but the first thing that I'm trying to figure out now is: how to trigger a transition from C#. For example, an NPC hits a border. What is the best way to have FSM react to that immediately without the need to poll the NPC?
     
  35. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    Thanks a lot!

    The best way to manualy trigger a transition from code would be to assign the "CheckEvent" condition (Utility/CheckEvent) in that transition and then in code send the event to the graph having the FSMOwner reference:
    Code (CSharp):
    1. var fsmOwner = GetComponent<FSMOwner>();
    2. fsmOwner.SendEvent("myEvent");
    You can also send global events like so:
    Graph.SendGlobalEvent("myEvent");

    Of course, if the transition should rely on some factor you already have access to, like for example -the distance of the NPC agent and to another specific object is less than a certain amount-, you can always use a direct condition check without the need to use events. For this example, a "Check Distance" condition.

    Let me know whenever you have any kind of questions :)
    Cheers!
     
  36. username132323232

    username132323232

    Joined:
    Dec 9, 2014
    Posts:
    477
    Thank you! This works great. You even anticipated a couple of other questions I was going to ask.:)
     
  37. OnePxl

    OnePxl

    Joined:
    Aug 6, 2012
    Posts:
    307
    I tried the NodeCanvas examples download from your site, in particular the Dialogue Tree example, but it gives an error after the first reply. Something to do with an animation. Also the soldier models looked really weird and seemed to be untextured?
     
  38. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    Hello,
    Sorry about it. It seems that the FBX import options were somehow lost. Can you please try and redownload the unity package from the website and re-import anew?
    I just reuploaded it hopefuly fixing this issue.

    Thanks a lot.
     
  39. Danirey

    Danirey

    Joined:
    Apr 3, 2013
    Posts:
    548
    Nice, thanks @nuverian!

    I'll think a bit on this. Anyway, using a bool check woorks fine, so i just have to change that!

    Cheers!
     
  40. nuverian

    nuverian

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

    A small update is submited on the store. Here are the changes:

    Task Generic Versions
    There is now a generic version for Action and Condition Tasks to alternatively define the AgentType if any, instead of using the [AgentType] attribute. This also relieves you from casting the agent as well. Here is an example:
    Code (CSharp):
    1. [AgentType(typeof(NavMeshAgent))]
    2. public class MyAction : ActionTask{
    3.  
    4.     public BBVector3 destination;
    5.  
    6.     protected override void OnExecute(){
    7.         (agent as NavMeshAgent).SetDestination(destination.value);
    8.         EndAction(true);
    9.     }
    10. }
    Code (CSharp):
    1. public class MyAction : ActionTask<NavMeshAgent>{
    2.  
    3.     public BBVector3 destination;
    4.  
    5.     protected override void OnExecute(){
    6.         agent.SetDestination(destination.value);
    7.         EndAction(true);
    8.     }
    9. }

    A small thing but improves workflow in the long run.
    Notice that all previous tasks will work fine. This usage is optional.

    Furthermore:
    • Improved CheckCSharpEvent condition task to not require a known agent reference and instead show a Type selection menu similar to the rest of the reflection tasks included with NC.
    • Optimized GetProperty, GetField, CheckProperty, CheckField tasks.
    • Made core classes 'partial'.
    • Fixed bug for when using SwitchBehaviour on GraphOwner.

    Cheers!
     
  41. username132323232

    username132323232

    Joined:
    Dec 9, 2014
    Posts:
    477
    I'm enjoying NodeCanvas and finding more and more great features. One drawback that I encountered is that adding NodeCanvas to a very simple scene seems to increase compile time from about a second to 10 seconds. Is this expected behavior and is there any way to remedy it?

    Just to clarify, I'm referring to switching from MonoDevelop back to Unity Editor. So, a 10-second delay is significant.
     
  42. nuverian

    nuverian

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

    I am glad you like NodeCanvas.
    I've also noticed Unity taking a lot of time to compile any project sometimes for unkown reasons to me. Closing Unity and re-opening always fixed the issue, but thats irelevant to NodeCanvas and more of a Unity thing.
    Can you please confirm that?
    I can't think of any reason to be an NC fault.

    Thanks
     
  43. username132323232

    username132323232

    Joined:
    Dec 9, 2014
    Posts:
    477
    Sorry, restarting Unity didn't help. I also created a separate project just to verify this, so I'm pretty sure that my results are correct.

    It seems that Unity recompiles the entire scene every time a change is made to any of the scripts. Do you have any suggestions? I hope we can find a solution :)
     
  44. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    I really cant seem to reproduce this some way. I am most than certain its irelevant to NodeCanvas.
    So your new project was compiling fine with other scripts untill you add NC, at which point and on it takes 10 sec?

    Thanks
     
  45. username132323232

    username132323232

    Joined:
    Dec 9, 2014
    Posts:
    477
    With a very simple project (just one script, a cube and a 2-state FSM) the compile time changes from under 1 second to 3-4 seconds.

    Here are the steps:
    1. Create a new project.
    2. Add a cube.
    3. Add a script to the cube.
    4. Open the script and add a space. Save.
    5. Return to Unity.

    There is no "Compiling Please Wait ..." message.

    6. Import NC.
    7. Repeat 4, 5.

    There is no "Compiling Please Wait ..." message.

    8. Add FSM to the cube.
    9. Repeat 4, 5.

    Observe "Compiling Please Wait ..." message for at least 3 seconds.

    10. Add a couple of states to the FSM.
    11. Repeat 4, 5.

    Observe "Compiling Please Wait ..." message for about 4 seconds.
     
  46. nuverian

    nuverian

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

    I can't really handle how Unity compiles the scripts and it's data. In my machine I always get the same time regardless of the scene which is around 5 seconds.
    There is no special code in NC which can affect compile time in some way. This is totaly up to Unity.

    Thanks
     
  47. Shorodei

    Shorodei

    Joined:
    Dec 7, 2013
    Posts:
    8
    Hello, I got this recently, and my biggest pain point has been the inability to add a "Transform" variable to the blackboard (it doesn't appear in the add variable list). Also, assigning a transform to a dynamic variable in a BT (sequencer) or FSM also doesn't work on me, as the next action down the line says the dynamic variable is null. What am I doing wrong?

    Specifically, here was my node chain:
    Execute function -> get_child (int 0) ___ save as "child1"
    MoveToGO -> $"child1" ____ <b>Task Init:</b> A required BBVariable value for Task 'Move To Game Object', is not set! Field: 'target'

    ++++++
    Edit: I just realized that the reason was there was no implicit GameObject -> Transform casting done. Shouldn't this be a default?
    And I still don't know why the Blackboard cannot have a Transform var.
     
    Last edited: Jan 31, 2015
  48. nuverian

    nuverian

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

    You can add a Transform variable or other UnityObject variables by adding a "UnityEngine/Object" and then selecting the type you want by clicking the small button on the right of the GUI control.
    ChangeType.png

    GameObject has no operator to be casted to Transform and NC doesn't handle this behind the scene automaticaly.
    If there was the possibilty to add operator overload extensions in C#, I would certainly would have done that though.

    Cheers!
     
  49. Pajaroide

    Pajaroide

    Joined:
    Sep 19, 2012
    Posts:
    34
    Hello! This is probably a silly question but is there a 2D equivalent to the "Mouse Pick" actions and conditions? Also, DynamicVars don't seem to be available for iTween actions, is that the intended behaviour?

    Cheers :)

    Edit: Also, this is probably me being dumb but I can't find the “Convert To SubTree” option when right clicking a node.

    Edit2: :confused: When using FSMs, could it be possible that when dragging from a state's connection to an empty space in the canvas it could create an action state? This already happens when using BTs... small video of what I mean: https://gfycat.com/GiftedArcticKinglet
     
    Last edited: Feb 4, 2015
  50. Disastercake

    Disastercake

    Joined:
    Apr 7, 2012
    Posts:
    317
    I just bought NodeCanvas and I'm feeling pretty good about it so far. =) It's got a bit of a learning curve, but I think that after mastering it that implementing in complex AI will be much easier than it was previously for me.

    There are some things I can't figure out though...

    1. How can I store a Transform.Position into a vector3 local variable? I want to store the position that the AI last saw the player at so when they lose sight they still run to that point, but I can't seem to set the Vector3 from anything other than another Vector3. At the moment, I simply have a script constantly updating the blackboard's Vector3 global variable with the player's position every frame. This seems un-intuitive and a waste of resources, however.
    2. How can I check distance between the AI's Transform.Position and a Vector3 point? I'd like to check if they are at the spot the player was last seen. I imagine there will be other comparisons that I will also want to check that aren't completely symmetrical value types.
    I was able to successfully create custom actions to solve the above problems, but I'd be very surprised if they weren't featured out of the box.

    A couple questions:
    • Do you cache the transforms and gameobjects that are being checked? I looked and it seems as if you're grabbing gameObjects and transforms without any caching in these action scripts. It would probably increase performance if they are cached somehow. A good place to put it would be in the BehaviourTreeOwner or equivalent classes. Then when you tell it to use its own transform in the node editor, it would use that cached variable.
    • Another good place to cache the transforms would be in the BBGameObject object since it seems that GameObjects are used when what you're really accessing is the Transforms.
    • Have you considered offering overloaded methods that use hash integers instead of strings for performance? If I have to access many variables every frame externally, using strings with reflection may have unnecessary overhead. As an example: Mecanim actually uses both strings and hashes to allow for better performance in situations where the developer can create the hashes ahead of time.
    Thanks for your time!
     
    Last edited: Feb 4, 2015