Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

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

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

  1. Shadeless

    Shadeless

    Joined:
    Jul 22, 2013
    Posts:
    136
    @nuverian
    Hey again, so I thought that once a transition happens the OnStateEnter callback is called only once. But it seems to get called multiple times.
    Code (CSharp):
    1.     public void OnStateEnter(IState state)
    2.     {
    3.         if(state.name == "Falling")
    4.         {
    5.             Debug.Log("Fall");
    6.         }
    7.     }
    So Fall appears multiple time in the Console.

    When I look at the NC Editor it all looks fine. Why would this be happening?

    Also, is there a way to create Action Tasks which only execute on state enter?

    Cheers

    Edit: Apparently it's because of the transitions from Any State, they transition to the state if the conditions are met even if you are already in the state. How do you stop this behavior?
     
    Last edited: Nov 24, 2015
  2. sanpats

    sanpats

    Joined:
    Aug 24, 2011
    Posts:
    343
    Add more condition to check if it is already in the state.
     
  3. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    Hey,
    As you found out, "AnyState" transitions to the target state when the condition is true, regadless of if that state is running or not, leading to constantely retriggering that state.
    One solution would be what sanpats said, to use some more conditions in a ConditionList for the transition.

    On the other hand, I just went ahead and added an option in the AnyState node called "No Retrigger Running States". What this does, is obviously what you are after here. :)
    I can PM you the code changes if you want.

    Cheers
     
  4. Shadeless

    Shadeless

    Joined:
    Jul 22, 2013
    Posts:
    136
    Yeah I tried that but since I have Nested States the FSMOwner gives the wrong currentState, but @nuverian said he'll fix it up. :D

    @nuverian
    Great job! :)
     
  5. sanpats

    sanpats

    Joined:
    Aug 24, 2011
    Posts:
    343
    You can create a Dynamic BlackBoard boolean parameter, then set it to true when entering the state in question; and check if it's true in the conditional transition from AnyState.
     
  6. DarkMasster

    DarkMasster

    Joined:
    Mar 23, 2015
    Posts:
    15
    Hello ! I have several issue on PC \ iOS when i do some performance tests. There is details:

    I create a simple app where i compair simple code realization and NodeCanvas FSM \ BT. My test is simple. I have 3 controllers:
    1. SimpleCodeContoller - select random point and move object to it.
    2. BehaviourTreeController - do same as 1. Using my simple actionTask - SelectRandomPoint + MoveToPoint.
    3. FSMController - same as 1. Using my simple actionTask - SelectRandomPoint + MoveToPoint.
    In have SceneManager with GUI for manage the test. GUI is simple:
    1. Slider - mange objects count - [100 ... 10000]
    2. ButtonSpawnSimple
    3. ButtonSpawnBT
    4. ButtonSpawnFSM
    Whe you push any button - they clear prevous spawned objects and spawn new objects. Thats all *))

    First of all i'll test it on PC. Memory is fine ! Momory overhead don't detected. But spwan time is horrible long !!! 2000+ objects with BT\FSM owners instantinate ove 40+ sec., on my PC. For compair simple objects just instatinate < 1 sec. What can i do for solve this problem ? Or what i do wrong ?

    Second i build my app on the device ( iPad 4 ) and run test, i have memory crash, when try to instantinate over 1000+ objects using BT \ FSM Owner. The i do some investigation and get some interested statistics:
    1. SimpleCodeContoller - spawn 500+ objects. Spawn time <= 1 sec, memory usage ~0.8 mb show in Unity Profiler ( SceneMemory ), total ~36,7 mb. show in XCode.
    2. BehaviourTreeController - can't spawn 800+ objects get crash, change on 500+. Spawn time ~= 18+ sec, memory usage ~= 129.1 mb show in Unity Profiler ( SceneMemory ), total 255+ mb. show in XCode.
    3. FSMController - same stats as in BehaviourTreeController.
    Now i attach screenshots for example it:

    App just started.


    Spawn 500+ simple controllers. As you can see memory usage is normal:

    Respawn 500+ BehaviouTree. As you can see memery usage horrible boosting !!! 255 mb total !

    Add more detailed stats in Unity pofiler - SceneMemory->MonoBehaviour = 128 MB.


    And last respawn 500+ FSM. As you can see memory usgae in unity is gone, but in Xcode its boosting again - 432 MB !!!


    Plz. Help me understand how it can be solved ! Any suggestion ? If need i cans send my test project for investigation. 1.png 2.png 3.png 4.png 5.png
     
  7. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    Hello @DarkMasster
    The deserialization performance is being fixed right now for the next immediate version, comming very soon. This is a known issue when instantiating objects right now relevant to how deserialization works.
    Please hold on until the next version.
    Thank you!
     
    hopeful likes this.
  8. sanpats

    sanpats

    Joined:
    Aug 24, 2011
    Posts:
    343
    That's great news.
     
  9. DarkMasster

    DarkMasster

    Joined:
    Mar 23, 2015
    Posts:
    15
    Great ! Thank you for replay !
     
  10. Shadeless

    Shadeless

    Joined:
    Jul 22, 2013
    Posts:
    136
    @nuverian
    Hey, I noticed that FSMs ignore timescale, is there an option to enable timescaling so the FSM is paused when timescale is 0? Since I have some FSMs that need to be paused when timescale is 0.

    Cheers
     
  11. emmcd3

    emmcd3

    Joined:
    Dec 16, 2012
    Posts:
    26
    Don't know if this was pointed out : Assets/NodeCanvas Integrations/Playmaker/PlayMaker Actions/EnableOwnerBehaviour.cs(37,36): error CS0123: A method or delegate `HutongGames.PlayMaker.Actions.EnableOwnerBehaviour.OnGraphFinished()' parameters do not match delegate `System.Action<bool>(bool)' parameters

    Ive create 2 spanking new project and still the same issue....
     
  12. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    Hey,
    No, they don't ignore timescale :)
    What's your use case? Is it relevant to events or coroutines in any way and if so can you please share?

    Thanks

    Hello,
    I have just updated the package. Please re-download from the resource section of the website here.
    Thanks!
     
  13. MuhaMed1

    MuhaMed1

    Joined:
    Nov 15, 2013
    Posts:
    2
    How come there are no any step-by-step video tutorial yet?
    Maybe you could start from a simple DialogueTree tutorial ?
     
  14. Shadeless

    Shadeless

    Joined:
    Jul 22, 2013
    Posts:
    136
    Are you sure that transitions aren't checked when Time.timeScale is 0?

    If so, I must be doing something wrong then.
     
  15. Blue-Wolf

    Blue-Wolf

    Joined:
    May 27, 2014
    Posts:
    20
    Thinking of picking NodeCanvas up. I appreciate it having HFSM/BT built together. However, we’re expecting to have a large number of agents loading/unloading regularly in the game; any ETA on the deserialization performance fix Nuverian? Thanks in advance!
     
  16. sanpats

    sanpats

    Joined:
    Aug 24, 2011
    Posts:
    343
    Hey @nuverian

    We have talked about this before. Any update on a setting to turn off Debug.Log in NodeCanvas & FlowCanvas? Sometime I wanna see them, sometime it's clustering the console. And I want to turn them off for the actual build for performance reason.
     
  17. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    Hey,
    It's just that english is not my native language, but I will see into making some in the end with subtitles. I need to finish the new website first though that I'm working on :)

    Hey,
    Sorry. I was confused of what you ment earlier. If you want transitions to not be checked at timeScale 0, please open up MonoManager.cs and in the Update method at line #70, please add at the top:
    Code (CSharp):
    1.             if (Time.timeScale <= 0)
    2.                 return;
    I will add this as well, so don't worry for updating later on.
    Cheers

    Hey,
    Thanks for your interest in NC. As soon as I finish the new website, I will complete the update and send it to the asset store. I will say in about 10 days at max the new version will be live.
    Let me know if you have any other questions :)
    Thanks!

    Hey,
    Sure. This will be included in the next version. It's already in the list ;)
    Thanks!
     
  18. Guacamolay

    Guacamolay

    Joined:
    Jun 24, 2013
    Posts:
    63
    Hi,

    I couldn't find this in the forums, but if I have a list as one of my Blackboard variables, how do I add/remove an element from the list at runtime? I've created a Vector2 list to hold coordinates for an AI character and would like to be able to access them from multiple nodes using the Blackboard if possible. Thanks in advance for your help
     
  19. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    Hey,
    There are several included actions/conditions that are relevant to lists that you can find under the "Blackboard/Lists" category. Under there you will also find "Add Element To List" and "Remove Element From List" actions amongst some others :)
    Let me know if these work for you.

    Cheers!
     
  20. Guacamolay

    Guacamolay

    Joined:
    Jun 24, 2013
    Posts:
    63
    Perfect, thanks! Everything else is working great by the way, you did a crazy good job on this asset!
     
  21. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    Hey, glad to know and thanks a lot! I apprieciate it :)
    I'm glad you enjoy NodeCanvas!
     
  22. chaneya

    chaneya

    Joined:
    Jan 12, 2010
    Posts:
    416
    Just wondering if anyone is using NodeCanvas with Apex Path.

    Will Nodecanvas need an extension to use Apex Path or will it just work?

    Thanks
    Allan
     
  23. alexthomasren

    alexthomasren

    Joined:
    Dec 24, 2013
    Posts:
    11
    Hi Nuverian,

    I see that we're able to have multiple behavior tree owners on a single GameObject. I see in documentation that you allowed this purposefully. But, is it a pattern that you recommend :)?

    Best,
    Alex
     
  24. nuverian

    nuverian

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

    Extensions are a way to streamline the workflow between NodeCanvas and some other asset. Most of the times the Script Control tasks will suffice to work with some asset depending on it's complexity and/or features. To be honest, I havent worked with Apex Path yet, so I can't really tell for that one.
    Of course if you are up to creating custom tasks, everything is possible :)

    If more people request an Apex Path integration, I will see to creating one.

    Cheers!

    Hey,
    There is not some pattern that I recommend regarding this matter. I just mention that it's possible because I had that question comming frequently. :)
    For example, some people wanted to use different behaviour tree owners for having different behaviour trees controlling different aspects of the agent, but personaly I would have done this using SubTrees instead within one behaviour tree owner. It's a matter of preference though.

    Cheers!
     
  25. sanpats

    sanpats

    Joined:
    Aug 24, 2011
    Posts:
    343
    Unity 5.3 stable release is out. Will we have new NC and FC soon?
     
  26. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    Yep! I'm working on that :)
     
  27. sanpats

    sanpats

    Joined:
    Aug 24, 2011
    Posts:
    343
    The zoom issue is now fixed in this version of Unity. So there isn't really any bug in your asset that I know of. However, the deserialize performance improvement is a very important feature! :)

    I also hope you can find a way for FC to work with iOS. NC is already working.
     
  28. Shadeless

    Shadeless

    Joined:
    Jul 22, 2013
    Posts:
    136
    @nuverian Hey, I just found a little bug I'm not sure if you're aware of it. When you delete an Action State that's the Start state, the Start is just floating there and is not assigned and this way you get an error when playing. This is trivial to fix by just assigning a start state manually, but I just wanted to report it to you.

    Cheers
     
  29. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    Hey,
    You just named my two highest priorities here :)

    Hey,
    Thanks for reporting, but I can't seem to replicate the issue :/. Could you provide a bit more info on how to replicate that?

    Thanks!
     
  30. Shadeless

    Shadeless

    Joined:
    Jul 22, 2013
    Posts:
    136
    Hey, this happened in 5.3 for me. But I reverted to 5.2.3 and it doesn't seem to occur in this version.
    In 5.3 I simply deleted the start node and the start was just floating there. But screw 5.3..
     
  31. Seith

    Seith

    Joined:
    Nov 3, 2012
    Posts:
    755
    @nuverian Hi, I just upgraded to Unity 5.3.0f4 and I get multiple warnings related to NC whenever I save a script:



    In case this isn't fixed already, could you please have a look at those? Thanks!
     
  32. alexthomasren

    alexthomasren

    Joined:
    Dec 24, 2013
    Posts:
    11
    Thanks for the quick reply!
     
  33. sanpats

    sanpats

    Joined:
    Aug 24, 2011
    Posts:
    343
    @nuverian

    I can't seem to add DialogueTree to a GlobalBlackboard variables and ActionTask BBParameter. I can add them to Monobehavior variables. I mean click and drag the dialogue tree to the respective receptacle in the inspector.

    Your new website seems to mentioned BT and FSM only, will DT support cease?
     
    Last edited: Dec 11, 2015
  34. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    Hey,
    I've tried 5.3 and didn't get this problem. So, if you happen to get it again and is possible, please let me know of a way to reproduce this :)

    Thanks!

    Hey,
    Yes, these warnings will be gone in the next release. Nothing to worry about :)
    Cheers!

    You are welcome!

    Hey,
    There is a know issue about that. Please drag&drop the DialogueTree component instead of the gameobject and it will work fine :)
    Dialogue Trees will definetely NOT be ceased! Quite the contrary, there will be a seperate website for them and will be release as a standalone asset that will though be free for all NC owners of course. This seperation is done to make NC more behaviour centric and dinstinct.

    Cheers!
     
    Last edited: Dec 12, 2015
    Seith likes this.
  35. sanpats

    sanpats

    Joined:
    Aug 24, 2011
    Posts:
    343
    That works. Thanks!

    Will the free DT for NC owner be downloadable through asset store?
     
  36. fenglin

    fenglin

    Joined:
    Feb 25, 2014
    Posts:
    3
    Hi,nuverian, when will the next version update, our product was released, if the AI deserialization performance can be improved, it would be a very happy thing:)
     
  37. cavila

    cavila

    Joined:
    Jun 4, 2013
    Posts:
    67
    Hi @nuverian,

    I've been having issues using the preferred types within node canvas. I'm able to see my class in the preferred types list window but I'm unable to use it in the blackboard. This is a partial class so I'm not sure if this is a known issue. Here's the signature of the class I'm having issues with:

    Code (CSharp):
    1. public partial class ArtificialIntelligenceSystem{}
    2. public partial class ArtificialIntelligenceSystem : ArtificialIntelligenceSystemBase {}
    Interestingly enough, I can reference and use the parent class "ArtificialIntelligenceSystemBase" in NC with no issues. Any ideas?

    Thanks
     
  38. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    Hey,
    You are welcome. Yes, the DT will be available from within the asset store for NC owners. The way I'm going to do this is that I would set an upgrade price from NodeCanvas equal to zero :)

    Hey,
    Glad to hear that. I have good news right in time!
    The deserialization has been fixed. It's now heavily optimized and very fast.
    I will send the new version to the asset store tomorrow.

    By the way, would you mind sharing your game?
    Cheers.

    Hey,
    The preferred types are filtered out if they contain no public method, property or field. I suspect the ArtificialIntelligenceSystemBase class has some of those and that's why it's shown in the menus. As soon as you add any public member to your derived class it will also show in the menus.

    Let me know if this works for you.
    Cheers!
     
  39. fenglin

    fenglin

    Joined:
    Feb 25, 2014
    Posts:
    3
    Well, this is a great good news :) I am very happy to share our games . However, it is another company responsible for the issue , currently operates only in mainland China , the Chinese version :)
     
  40. cavila

    cavila

    Joined:
    Jun 4, 2013
    Posts:
    67
    Disregard my last post. I added a simple "public void NC(){}" and that worked like a charm! Thanks!
     
  41. therocknwork

    therocknwork

    Joined:
    Apr 20, 2015
    Posts:
    3
    Hi, I'm trying to deserialize state machine with nested fsm. Both of them (main and nested) are serialized to text file in JSON format. After deserialization I'm getting original main FSM with empty nested FSM node.

    Code (csharp):
    1. var fsmData = System.IO.File.ReadAllText("Assets/FSMs/LimitedOfferDarkManaGoldMine.FSM");
    2. var fsmObject = new GameObject(name);
    3. var fsmOwner = fsmObject.AddComponent<FSMOwner>();
    4. fsmOwner.graph = new FSM();
    5. fsmOwner.graph.Deserialize(fsmData, false, null);      
    6.      
    7. foreach (var node in fsmOwner.graph.allNodes)
    8. {
    9.             if (node is IGraphAssignable)
    10.             {
    11.                 string filename = node.name + ".FSM";
    12.                 var fsmData = System.IO.File.ReadAllText("Assets/FSMs/" + filename);
    13.  
    14.                 IGraphAssignable assignableNode = node as IGraphAssignable;
    15.                 assignableNode.nestedGraph = new FSM();
    16.                 assignableNode.nestedGraph.Deserialize(fsmData, false, null);
    17.             }
    18. }    
    19.  
    So what should I do to deserialize nested FSM correctly and assign it to nested node?
     
    Last edited: Dec 17, 2015
  42. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    Hello,
    Even though I don't know what's your use case and why not use FSM assets instead of loading the json files directly :), I just tried your code and works fine. Are you sure that your node.name is the same as the file your are searching for, or that there is not some error in the console? Also, you should use ScriptableObject.CreateInstance<FSM>() instead of new FSM().

    Let me know.
    Cheers.
     
  43. therocknwork

    therocknwork

    Joined:
    Apr 20, 2015
    Posts:
    3
    I'm using deserialization from JSON, cos I need to download state machine in runtime from server, and yes, I've used debugger to check that there's file with correct name in my FSMs folder and fsmData isn't null or empty and contains my FSM in JSON format.

    Now I've changed
    Code (csharp):
    1. new FSM();
    to
    Code (csharp):
    1. ScriptableObject.CreateInstance<FSM>();
    but nothing changed, I still getting state machine with empty nested state machine in it.
     
    Last edited: Dec 22, 2015
  44. sanpats

    sanpats

    Joined:
    Aug 24, 2011
    Posts:
    343
    Hi the new Serializer is bug and break my project (no worry I use git so easy to revert). The boolean won't get saved, for example the conditional transition that check a blackboard variable will not save the boolean value ($XXXX = false <-- false can not be saved and will revert to true (default value) everytime I click play). And there are many weird behavior that I don't really understand yet, i.e. a checkevent transition from AnyState will not move to the destination state even the eventdata was sent already. All these works fine in the previous version.
     
    Last edited: Dec 22, 2015
  45. sanpats

    sanpats

    Joined:
    Aug 24, 2011
    Posts:
    343
    If you need any further info, please contact me.
     
  46. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    Hello,
    The problem was not that you called new FSM() instead of CreateInstance(), but it was just a suggestion, irrelevant of the issue. I was able to run your code posted above and deserialize a masterFSM + subFSM correctly and without errors.
    Your code is fine, correctly works here and is the correct way to do it :), so something else might be the problem. If you can, please PM me a reproduction case mini-project so that I can take a closer look to what might be possible be wrong in your case.
    Thank you!


    Thanks :)
     
  47. JMax

    JMax

    Joined:
    Apr 10, 2015
    Posts:
    4
    Incorrect parse Variable name when using multiple attachment name.
    If I use a global bb "/". sample: "Main_BB/Player/OnAsist"
    Need fix "BBParameter.cs"
    in


    Сorrectly:
    Code (CSharp):
    1.         private Variable globalVarRef{
    2.             get
    3.             {
    4.                 if (name != null && name.Contains("/")){
    5.                     var bbName = name.Split('/')[0];
    6.                     var varName = name.Replace(bbName + "/", "");
    7.                     var globalBB = GlobalBlackboard.Find(bbName);
    8.                     if (globalBB == null){
    9.                         return null;
    10.                     }
    11.                     var globalVar = globalBB.GetVariable( varName );
    12.                     if (globalVar == null){
    13.                         return null;
    14.                     }
    15.                     return globalVar;
    16.                 }
    17.                 return null;
    18.             }
    19.         }
     
    Last edited: Dec 27, 2015
  48. sanpats

    sanpats

    Joined:
    Aug 24, 2011
    Posts:
    343
    There is a misspelled word. When pasting a copied node/link, it show "Pase" in the context menu.
     
  49. JakeTBear

    JakeTBear

    Joined:
    Feb 15, 2014
    Posts:
    123
    Hey Nuverian, I attempted to create a sub tree from a branch, it saves the asset file but it seems the tree is empty. Any ideas on this?
     
  50. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    Thanks! I added this :)

    Thanks! I've fixed this now :)

    Hello!
    I can't really reproduce this problem here and it works fine on my end. :/
    Is there any error loged in the console? Maybe the nodes are off canvas (you can focus them with "F" key)?
    Please let me know. Thanks