Search Unity

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

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

  1. desyashasyi

    desyashasyi

    Joined:
    Nov 22, 2012
    Posts:
    73
    Hi Nuverian,
    I was updated to NC 1.5.2, but i am having problem. I want to put a condition in connection B. I tried many times by clicking the connection, but i cannot find where is the place to show the condition input. In previous NC version, It is easy to do it, but in current version i have difficulties. Thanks.


    NC.png
     
  2. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    Hello,
    The conditions on the connections of Behaviour Trees in v1.5.2 were removed on purpose in favor of using decorators instead, for a more streamlined workflow. Any previous connections will still show their conditions though so that it is backwards compatible.
    Some people liked it, some other hated the fact that I removed them. It is very easy to go back into allowing them though.


    Do you definetely prefer conditional connections instead of using conditional decorator nodes?
     
  3. Danirey

    Danirey

    Joined:
    Apr 3, 2013
    Posts:
    548
    Hi there,

    I didn't update to the latest version yet, but how should be used the conditional decorator?

    And another question: In the videos you can see that since the previous Update, all the debug text boxes don't appear close under the agent, now they show far under the agent. maybe i mess something in the update process?.

    And the last thing: I'll make the first try with the dialogues soon. I read in the documentation and saw it in the demo scenes and in your UI and there is a subscribe thing(
    I confess myself totally ignorant with this question, and with the previous too…). How may i subscribe to the DT events to get the text to show through the GUI? (JS# please! ;))


    Thanks a lot!
     
  4. desyashasyi

    desyashasyi

    Joined:
    Nov 22, 2012
    Posts:
    73
    Hello,
    Thank you for your reply. I see the reason. I need to study the new feature (decorators). But if possible, while i study it, i want to apply previous one, is it easy to allow the condition in connection?

    I have another question, maybe i need your suggestion.

    I plan to have database of dialog tree in my game project. each dialog has one or many keywords. If a keyword has selected, it effects to load another dialog node/tree in the database. Is it possible to use blackboard as database of dialog tree lists? However, I want to allow to reuse the database of dialog (tree) in any added further game levels. Can you suggest me the good way to achieve this purpose?

    Thanks a lot.
     
    Last edited: Jul 15, 2014
  5. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    Hello,
    By conditional decorators I just mean the use of Interruptor and Accessor which can be assigned a condition like you've already used them :)

    The Debug Log position is fixed in the new version. It was just a bug (one of the reasons I urged you to update in previous post :))

    Regarding dialogues, you make use of those dispatched events in case you want to create your own UI. Those events have nothing to do with c# events and even in JS its used the same as the example for C# in the docs:

    Code (JavaScript):
    1.  
    2. import NodeCanvas;
    3. import NodeCanvas.DialogueTrees;
    4.  
    5. class Example extends MonoBehaviour{
    6.  
    7.     //Subscribe to event called OnActorSpeaking
    8.     function OnEnable(){
    9.         EventHandler.Subscribe(this, DLGEvents.OnActorSpeaking);
    10.     }
    11.  
    12.     //Unsubscribe this from all events
    13.     function OnDisable(){
    14.         EventHandler.Unsubscribe(this);
    15.     }
    16.  
    17.     //Function with same name as event is called when the event is raised
    18.     //This could be a coroutine as well
    19.     function OnActorSpeaking(info : DialogueSpeechInfo){
    20.         Debug.Log(info.statement.text);
    21.         info.DoneSpeaking();
    22.     }
    23. }
    24.  


    Hello,
    The decorators are there long time now. It's not something new :)
    Yes, it's easy to use the conditions on the connections again. You have to open up BTConnection.cs and instead of deriving from Connection, derive it from ConditionalConnection. BUT, be aware that if you do so, then when you update to next version you will lose those conditions again, in case I haven't done so as well and i still don't know whether I do that yet, unless there is much demand to bring them back.
    I'd really suggest that you just use an Interruptor or Accessor in place where you would previously use a conditional connection.

    Can you please provide more information regarding the dialogue tree question? I didn't quite understand what you are after. Sorry :/
     
  6. Danirey

    Danirey

    Joined:
    Apr 3, 2013
    Posts:
    548
    Hi nuverian,

    Nice, i'll update ASAP! And i think i never used a condition connection in a BT, you are right. :p

    Sometimes because the language i loose myself…:oops: with the explanations.

    The dialogue trees: i'm sorry, but i don't know if i get it. When you say "your own UI", it means that you control the UI with a custom code, and when you need it, you get the events to show the text dialogue? Lets say i want to make something with the new GUI that Unity will launch this summer. How can i get the text to fill a label, but making the dialogue tree wait until the text finishes to be writed? You will have to get WHEN the dialogue SAYS something, and pause it until the full text appears. and then you get the next dialogue node text and so on… I assume that this is what the code you posted does, right?

    Sorry and thanks again!
     
  7. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    Hey no problem :)

    The posted code above simply logs the said 'Statement' and then immediately calls back (DoneSpeaking) so that the dialogue tree continues.
    I don't know how the new UnityGUI will work but lets do what you asked with OnGUI. Point is, that a string get's written over time and when it's done, we call DoneSpeaking. Here it is:

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using NodeCanvas;
    4. using NodeCanvas.DialogueTrees;
    5.  
    6. public class TypeInExample : MonoBehaviour {
    7.  
    8.     string displayText;
    9.  
    10.     void OnEnable(){
    11.         EventHandler.Subscribe(this, DLGEvents.OnActorSpeaking);
    12.     }
    13.  
    14.     void OnDisable(){
    15.         EventHandler.Unsubscribe(this);
    16.     }
    17.  
    18.     public IEnumerator OnActorSpeaking(DialogueSpeechInfo info){
    19.  
    20.         displayText = info.actor.actorName + ": ";
    21.  
    22.         for (int i = 0; i < info.statement.text.Length; i++){
    23.             displayText += info.statement.text[i];
    24.             yield return new WaitForSeconds(0.05f);
    25.         }
    26.  
    27.         yield return new WaitForSeconds(1.2f);
    28.         displayText = null;
    29.         info.DoneSpeaking();
    30.     }
    31.  
    32.     void OnGUI(){
    33.         GUILayout.Label(displayText);
    34.     }
    35. }

    Code (JavaScript):
    1. import NodeCanvas;
    2. import NodeCanvas.DialogueTrees;
    3.  
    4. class TypeInExample extends MonoBehaviour {
    5.  
    6.     var displayText : String;
    7.  
    8.     function OnEnable(){
    9.         EventHandler.Subscribe(this, DLGEvents.OnActorSpeaking);
    10.     }
    11.  
    12.     function OnDisable(){
    13.         EventHandler.Unsubscribe(this);
    14.     }
    15.  
    16.     function OnActorSpeaking(info : DialogueSpeechInfo) : IEnumerator{
    17.  
    18.         displayText = info.actor.actorName + ": ";
    19.  
    20.         for (var i = 0; i < info.statement.text.Length; i++){
    21.             displayText += info.statement.text[i];
    22.             yield WaitForSeconds(0.05);
    23.         }
    24.  
    25.         yield WaitForSeconds(1.2);
    26.         displayText = null;
    27.         info.DoneSpeaking();
    28.     }
    29.  
    30.     function OnGUI(){
    31.         GUILayout.Label(displayText);
    32.     }
    33. }

    Just place this on any game object and run a dialogue tree. The expected will happen :)
    By the way, when new GUI comes around in 4.6, I will make a new example GUI and include that in the package.
     
  8. Danirey

    Danirey

    Joined:
    Apr 3, 2013
    Posts:
    548
    HAHAHAHA!!!! Got it! Thank you so much! :D

    I cant wait to make a full scene with the three NodeCanvas Trees working together.

    This is really fun!


    Cheers!
     
  9. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    Hey you are welcome! Glad to know you enjoy it :)
     
  10. msl_manni

    msl_manni

    Joined:
    Jul 5, 2011
    Posts:
    272
  11. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
  12. msl_manni

    msl_manni

    Joined:
    Jul 5, 2011
    Posts:
    272
    You are welcome. I would like to see more example Graphs of different logics and implementation. That would really help with BT. :)
     
  13. desyashasyi

    desyashasyi

    Joined:
    Nov 22, 2012
    Posts:
    73
    Hello... Thank you for kind response. Now, I understand how interruptor work. About list of dialog tree as database, i mean I want to create dialog tree as much as possible. I consider to make a list/array of this dialog and i need to call a specific dialog by keyword which save on the blackboard. Is it possible? ooo one more about dialog, how to get random node in dialog tree. I want to create a dialog tree which contain many 'random say', and then i need to access this say/node as single dialog. I will implement it as news highlight in the game. I will make dialog tree with many nodes (as collection of news). An then i need to show the content of node (say) randomly or by a keyword. But i don't know, is there node ID in the dialog tree?

    I was try others BT plugin, i said i love node canvas. However, compare to others BT editor, i have some suggestions for NC next update.

    1. Ability to disable/enable condition/action in a node (as i mentioned before, it is like playmaker feature)
    2. Ability to enable/disable a node
    3. Ability to expand/colapse a node with child
    4. Ability to select more than one node, so i can delete/move/copy the nodes.
    5. Ability to not show info of a node, so the node has simple appearance.

    Honestly, i impressed using Behaviour Designer (opsive) editor, but the workflow of NC (including FSM and Dialog tree) is better than previous one. So, perhaps i suggest you to update NC editor more 'friendly'. Those five suggestions are just example. I am sure, i have others expectation :). Sorry to bother you with My comments :-D. Thank you.
     
    Last edited: Jul 19, 2014
  14. nuverian

    nuverian

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

    If you simply want an actor to say a single dialogue line you don't really need to use the dialogue editor. You can just call dialogueActor.Say(string text, Action callback). This will dispatch the required events like a 'Say Node' does. So you can have a list of strings in one of your scripts and call this function with a random selection amongst those strings.
    Those strings could of course be on the blackboard, or a List<string> custom blackboard variable which you can create very easily (let me know if you need help with that).

    If you indeed want to run a complete dialogue tree and not just a single line of dialogue, you could make a List<DialogueTree> in your script or a List<Object> in the blackboard (and set it to DialogueTree type with the small button on the right of the variable). Then for a keyword thing, you could use the dialogue tree's name for example. You will of course need to write some code. Let me know if you want a code example.

    There are many ways to get one or more nodes in a graph from code:
    List<T> GetAllNodesOfType<T>()
    T GetNodeWithTag<T>(string name)
    List<T> GetNodesWithTag<T>(string name)
    List<T> GetAllTaggedNodes<T>()
    T GetNodeWithName<T>(string name)
    List<Node> GetRootNodes()

    (Dialogue nodes can't be taged now, but will be able in next version)


    So you can't exactly get a random node automaticaly, but you can get a list of nodes and then pick one randomly in code. In any case, I think that the first suggestion is better suited in your needs since you want (as far as I understoond) to play a single dialogue text.
    Let me know if I misunderstoon your needs.

    As for your suggestions:
    1. Done for lists.
    2. You can already disable/enable a node by instead enable/disable it's input connections, but I've added a disable on right click menu for convenience.
    3.Ok. I've done this.
    4. I'll do this after the next version, but keep it mind that you can move a node and all it's children together by holding down SHIFT.
    5. It's already possible to hide the summary info for that reason. It's under Options window menu "Show Task Summary Info". You can turn it off if you want.

    There are many more stuff in version 1.5.3. I will post full changes later on :)
     
  15. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    Alright. So Version 1.5.3 is about to go. Here are the new (rather many) cool stuff:

    -- WORKFLOW --

    • Rectangle Node Selection.
    • Branch nodes can now get Collapsed / Expanded as to hide/show child nodes.
    • Nodes can now be Disabled / Enabled on top of only disabling the connection.
    • Branch nodes can now get Deleted Recursively as a whole from their context menu.
    • Task assignable nodes now have a Copy/Paste Assigned Task in their context menu!
    • Added a new 'Task Wizard Editor' window to easily create new Tasks with options for namespace, attributes etc.
    • Added 'OnGizmosSelected' in tasks to show custom gizmos only when the task is selected/inspected in the editor.
    • Vastly improved the Light Theme (at last).
    • Curved connections are now a bit wider.
    • Using obsolete tasks will now throw a warning in the console.

    -- SCRIPT CONTROL & VARIABLES --

    • Added Enum Blackboard Variable which can be set to any Enum type like the Object variable does!
    • As such, all function with any Enum type parameter in Script Control tasks will also show up to be selected. The value can either be assigned directly or taken from a blackboard variable. This open up a huge list of new function to be called from Script Control Tasks.
    • The Execute Function Task can now start & run Coroutines! It will run for as long as the coroutine is running and if the task get interrupted, so will the coroutine stop. Super useful!
    • Script control tasks will now also show function with any Unity Object type parameter instead of only Components (eg AnimationClip, AudioClip etc)
    • The Check Function condition task can now accept one paramter.
    • Added Quaternion blackboard variable type.
    • Added AnimationCurve blackboard variable type.
    • All overloaded methods in Script Control selection will now properly show up.
    • The Get/Set Field will properly show up derived field types.
    EnumScriptControl.png EnumVar.png


    AnimatorMethods.png A list of the now selectable Animator methods just for the shake of it :)



    -- FURTHERMORE --
    • Tasks in list can now be disabled/ enabled!
    • Added BT Guard Decorator. It can be set to guard a resource 'token' for the agent. Resource guarding is global to all of the agent's behaviour trees.
    • The BT Accessor decorator now has a 'Dynamic' option as well, to make possible to interrupt the decorated child node if the condition no longer holds true. This completely replaces the now obsoleted BT Conditional Connections functionality.
    • API for adding, removing, connection nodes moved in runtime code so that you can change the graph at...runtime.
    • Improved API for interfacing with graphs and nodes from code. A documentation page will follow regarding that.
    • OnAnimatorMove can now also be used in tasks.
    • Graphs now have an elapsedTime property.
    ActionList.png
    Guard.png




    -- FIXES --
    • Fixed Timeout condition task.
    • Improved GetInputAxis.
    • Script Control tasks will now throw initialize error instead of simply returning failure.
    • BT Iterrator will no longer remove null objects from it's target list.
    • BT Repeater number of times can now be assigned a blackboard variable as well.
    • Fixed some nested graph instantiation issues.
    • Using private methods for Unity Events and EventHandler is now possible again.
    There are also a bunch of new tasks that I will post the complete list later on since Im still working on those.
    Stay tuned...
     
    Last edited: Jul 20, 2014
  16. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,162
    is it possible to send global event(like "Game Over") to all FSMs ?

    i found Graph.SendGlobalEvent(). i think this will work. what are other global functions like this? where can i find the list of them in documentation?
     
    Last edited: Jul 20, 2014
  17. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    Yes that's the one. The SendEvent action also has an option to send the event global.
    What other global functions are you after?
     
  18. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,162
    I do not know what can be global more :)

    is there any simple action like "set position" ? i can write it easily, but if you already did i prefer to use it.

    i could not do that;
    i have an empty game to set target position. i want to use itween action. it uses fixed position or vector3 from blackboard. i can set my game object as GameObject type to the blackboard. you should add Target Transform property to iTweenMove action to use game objects as target transform.
     
  19. nuverian

    nuverian

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

    About 'set position', you can just use Set Property action to set any property on any component, thus there is no need for a SetPosition action :). It would only clutter the available actions.

    Alright, I will add a game object target in ITween actions, but Im also working on a way to allow Vector3 variables to also select a blackboard game object variable directly since that is rather common.

    Cheers :)
     
  20. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,162
    i could not change position with set property. i will check it again. i wrote my set position :)

    i have a problem with collision events. i use agent and method public void OnCollisionEnter2D(Collision2D coll). fsm calls this method even state is not active.i thought fsm calls this method when state is active. in execute method i prepare my variables. early call of this method cause null pointer exceptions.

    i used following check; i still think it is a bug :)

    public void OnCollisionEnter2D(Collision2D coll)
    {
    if (!isRunning)
    return;

    Why NC does not have BB set int action :) i found bool, float but no int.

    i need conditional actions in FSM like play audio if player settings says playMusic is True.i can do it with behavior tree. i can use just one behavior tree in a state. can i use some actions and behavior trees in an FSM state?
     
    Last edited: Jul 22, 2014
  21. desyashasyi

    desyashasyi

    Joined:
    Nov 22, 2012
    Posts:
    73
    Hii Nuverian,
    Thank You for the feature of Next update. :)
    About your suggestion of my intention to have dialog collection and also about one say/speak, I will try it soon. However, i was tried to run two dialog graph in same time. First dialog graph is for dialog between PC and NPC, and second graph is for news/information. However, I cannot achieve the result of dialoguer graph for news/information. NGUI label that i used for news/information also shows the content of dialog between NPC and PC. How to solve the problem? I cannot find the documentation of Dialog Tree to use two dialog graph in same time with different GUI. Thanks.
     
  22. bkw

    bkw

    Joined:
    Sep 20, 2013
    Posts:
    49
    Hi, I'm having an issue with custom variables.

    Using your Hero class example. I created a prefab that's structured like this:
    Code (CSharp):
    1. GameObject (BehaviourTreeOwner)
    2. |- GameObject (BehaviourTree)
    3. |- GameObject (Blackboard)
    The blackboard has a variable of Hero type.

    When I quit Unity and load the project/scene again, I get a behaviour script missing for that Hero variable on the Blackboard GameObject. Any ideas why? It seems to be ok if I don't prefab the thing and keep it in the hierarchy.

    Thanks
     
  23. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    You are welcome. Things had to be done :)

    The current DialogueUI sample included, can show only one dialogue at a time. I will make it possible to show more dialogue texts in the next update.
    I really think though that for the news/info text you don't really need the dialogue tree system, unless you you actually use the tree as in multiple branches/non linear :)

    Hello,
    Please make sure that the 'HeroData : VariableData' class is in a script that have the same name.
    This is not required for the BBHero class though.
    Sorry, I will add a validation safety check now.
    Last but not least make sure that the actual Hero is [Serializable]. Just saying :)

    By the way, in the update incomming now, you will be able to make any BBVariable of custom type or not, just like:
    public class BBHero : BBVariable<Hero>{}

    This really cant get easier :)
     
  24. desyashasyi

    desyashasyi

    Joined:
    Nov 22, 2012
    Posts:
    73
    Hi Nuverian,
    Thank you for your response. Yes, I consider to use dialog tree as news/information in the game. Because i need the ability to jump to another dialog tree. When player clicked a shown news, the others dialog contained information or question will be show.

    About creating custom variable, i tried to create list of string. I consider to apply your suggestion for NPC single say/speak. I have idea that NPC can approach the PC. While it move to PC, NPC will do some speaks/says. I want to show NPC speak in HUD text, but it will do randomly or based on a keyword. I can create the list using this script.

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections.Generic;
    3.  
    4. namespace NodeCanvas.Variables{
    5.  
    6.     [AddComponentMenu("")]
    7.     public class StringListData : VariableData{
    8.  
    9.         public List<string> value = new List<string>();
    10.  
    11.     }
    12. }
    But i confused how to make this list appeared in NC editor, so i can forward/pass the variable content to another variable or GUI system. Thanks.
     
  25. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,162
    Komşu, what about my questions? :) i edited my last post.
     
  26. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    Hello,
    I am not sure what you mean :) Tasks must make use of that variable in some way.
    The new version will include a List<string>variable and some tasks to make use of that type of variable.


    Sorry atmuc, I missed your post edit.

    Please let me know if and why the Set Property doesn't work.
    Indeed I will fix when the events are called to do so only when the state is active.
    I've added a check/set Int now :)
    Can you please carify your last question? I am not sure I follow :)


    Thanks
     
  27. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,162
    set property failure may be my mistake.i am converting my game from my fsm coding to your product. when i finish all i will check it again.

    last question;
    in a state you can add many actions. i need {action A, Embedded Behavior Tree, Action B }. in embedded BT i will add a sequence to check a variable and play sound. so i will have a conditional action in a state :) for solution i do not want to make many state instead of single state for this situation.

    minor bug; when i move mouse scroll up/down over NodeCanvas window grid moves.

    another minor bug; i added BBBool variable to my action. i see dropbox to select global variable from BB. i clicked another game objects. i clicked by state and action to set this bool variable. it shows free text field. i cannot say how to regenerate this case :-( it is ok when delete and re add this action. you should check when it shows free text input while there are global BB and bool value. i did not checked if it will be ok if i close and open unity.

    Edit: Ah sorry, you had a forum. i should have written those there.
     
    Last edited: Jul 22, 2014
  28. nuverian

    nuverian

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

    You can add an 'embeded BT' as an action task, by creating a very simple action task. Here it is:

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using NodeCanvas.BehaviourTrees;
    4.  
    5. namespace NodeCanvas.Actions{
    6.  
    7.     public class BehaviourTreeAction : ActionTask {
    8.  
    9.         [SerializeField]
    10.         private BehaviourTree _behaviour;
    11.         public BehaviourTree behaviour{
    12.             get {return _behaviour;}
    13.             set
    14.             {
    15.                 _behaviour = value;
    16.                 if (_behaviour){
    17.                     _behaviour.agent = agent;
    18.                     _behaviour.blackboard = blackboard;
    19.                 }
    20.             }
    21.         }
    22.         public bool repeatBehaviour = false;
    23.  
    24.         protected override void OnExecute(){
    25.             behaviour.runForever = repeatBehaviour;
    26.             behaviour.StartGraph(agent, blackboard, EndAction);
    27.         }
    28.  
    29.         protected override void OnStop(){
    30.             behaviour.StopGraph();
    31.         }
    32.     }
    33. }

    You can assign the action task a standalone behaviour tree created through "Window/NodeCanvas/Create Behaviour Tree". The property setert here is simply so that the blackboard and agent are passed in edit time so that the behaviour tree uses the same variables for example.

    In any case though, I think it will be an overikil to use a whole behaviour tree for a simple "if x then y". I have something in mind for that :)

    The grid graphics me slightly for a brief moment, yes thats a know bug.
    If you have NC editor already open and you edit a task script by adding a new BBVariable like you did, the BBVariable dont initialize. All you have to do is re-open the editor and it will be fine. Is that what you mean?

    Also make sure that if you are using global blackboards, that they have different names. I will add a safety check for that in next version.
     
  29. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,162
    thanks for code. it will solve my problem. any other lighter solution will be better :) now i extended audio play action and added bbbool variable to check condition. so much customization will not good but it is faster solution for me now.
     
  30. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    I have a project with a BT associated with a character. I'm creating a new project and want to copy that BT into the new project. It doesn't look like the tree itself is an asset although I can see the 'BehaviorTree Graph' node in the Hierarchy.

    Can I export this and import it into my new project so I don't have to recreate the whole tree again?

    Thanks!
     
  31. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    You are welcome. Just be careful when you update as to not overwrite source changes :)
     
  32. nuverian

    nuverian

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

    Considering that you have NC in that other project imported, you can make a prefab of the Behaviour Tree and import that prefab to that other project :)
     
  33. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    Alright here is the list of new tasks that will be included in 1.5.3 I said I'll post:

    • DebugDrawLine
    • PlayAnimationAdvanced (Legacy Animation)
    • SaveBlackboard
    • LoadBlackboard
    • MoveTowards
    • MoveAway
    • RotateTowards
    • CheckInt
    • SetInt
    • SampleCurveAt
    • EvaluateCurve
    • CreateGameObject
    • NormalizeVector
    • GetLineCastInfo
    • GetLineCastInfo2D
    • GetLineCastInfo2DAll
    • GetOverlapSphereObjects
    • GetDistance
    • GetListCount
    • GetAllChildGameObjects
    • FindObjectOfType
    • FindObjectsOfType
    • CurveTransformTween
    • WaitMousePick
    • ClearList
    • ShuffleList
    • AddListObjects
    • AddListStrings
    • RemoveListObjects
    • RemoveListStrings
    • PickListObject
    • PickListString
    • PickListVector
    • PickListFloat
    • PickRandomListObject
    • PickRandomListString
    • PickRandomListVector
    • PickRandomListFloat

    • ListContainsObject?
    • ListContainsString?
    • ListIsEmpty?
    • StringContains?


    Furthermore I managed to squiz in some further improvements for the version:

    • The CheckProperty condition task can now check any property type instead of only boolean.
    • The CheckFunction condition task can now check any property type instead of only boolean.
    • Added List<string> variable.
    • Added List<float> variable.
    • Added List<Vector3> variable.
    • Made even easier to create any custom variable type
    • ConditionList is now re-orderable
    • Fixed SendGlobalEvent
     
    Last edited: Jul 23, 2014
  34. bkw

    bkw

    Joined:
    Sep 20, 2013
    Posts:
    49
    Thanks! That did the trick.

    Anyone have any good resources on how to design behaviour trees? I'm trying to figure out how to make things more modular and I can't get my head around how to manage data on the blackboard. For example, if I have a tree that has subtrees, flee, attack, and idle.
    Code (CSharp):
    1. - Dynamic Selector
    2. |- Flee
    3. |- Attack
    4. |- Idle
    In attack, I store my attack target on the blackboard (say it's a game object reference). If i'm in the middle of running Attack, and I need to flee, where would I get the chance to clear that attack target blackboard reference? Do I have to build it into the Flee tree?
     
  35. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    Hey,
    I've gathered some interesting resources. You can find the links online at:
    http://nodecanvas.com/documentation/node-systems/behaviour-trees/

    More specificaly about your case.
    Personaly I wouldn't store the 'attack target' within the Attack branch/tree as it seems more logical that we have an attack target already if we are to be in the attack branch. The Attack branch should care for what happens after that.

    The way I would go for it, would be to add an Accessor decorator above the Attack branch and check 'if target != null'.
    Then I would set the target within the Idle branch and clear it (null) within the Attack branch if for example target gets far away.
     
  36. desyashasyi

    desyashasyi

    Joined:
    Nov 22, 2012
    Posts:
    73
    Thank you for the response, I will wait next update :).And i will discuss my problem later after i try new feature in next update.
     
  37. desyashasyi

    desyashasyi

    Joined:
    Nov 22, 2012
    Posts:
    73

    Hello Nuverian,
    These are awesome update. I cannot wait to try the features.
     
  38. bkw

    bkw

    Joined:
    Sep 20, 2013
    Posts:
    49
    Thanks, I'll check out those resources. So many articles online explain how BTs work, but rarely do they teach you how to design the trees themselves. Hopefully I'll find something there.

    With your design, if the attack branch is responsible clearing the attack target, what happens if it's preempted by the flee branch? Should flee also know of the attack target and clear it at some point? This kind of makes sense, but it also means that flee, attack, and idle are not really that modular right? I can define the three branches as subtrees, but really they have some knowledge of each other built into them?
     
  39. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    You are welcome.
    Alright then :)

    The only common point of reference for all 3 subtrees will be a variable named 'target' and of type GameObject for example.
    As long as each tree itself knows what to do with that variable, those trees don't really have knowledge with one another, but rather they communicate through that common variable.
    So for example, if you take that Attack subtree and use it on another agent, as long as that agent's blackboard has a variable named 'target' that is also of type 'GameObject', the Attack subtree's tasks will "rehook" the variable and deal with it in the subtree's scope.

    Hope that makes sense :)
     
  40. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Hah... That should have been obvious. I'll try that. Thanks!
     
  41. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    It seems I can't stop adding features! :) Here is a hot one:

    Sync Mecanim Parameters

    It is now possible to sync any blackboard variable (bool, float, int) with an Animator's parameters.
    You simple specify the names of the parameters you want to sync and those animator parameters will always be synced with the respective blackboard variables.
    In effect you can control mecanim entirely through NodeCanvas and in..sync, without the need to getting, setting, checking the said parameters since they will always be the same as the blackboard ones.

    MecanimSync.gif

    I guess that prety much covers the mecanim support :)
     
  42. Marble

    Marble

    Joined:
    Aug 29, 2005
    Posts:
    1,268
    That is extremely useful, Nuverian! No more scripts clogged up with Mecanim hashes and verbose AnimatorController method calls.
     
  43. bkw

    bkw

    Joined:
    Sep 20, 2013
    Posts:
    49
    Are there any easy tweaks we can do to affect how the nodes look? Maybe something in the NodeCanvasSkins? I'm trying to squeeze more nodes on the NC window while working on a laptop. Looking and poking around in NodeWindowGUI on Node.cs right now, but curious if there's anything official or quick and dirty.
     
  44. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    Indeed, it saves quite some time :)

    To squeez in the most nodes possible, set them to text mode, check off 'Show Summary Info' in the options., and possibly set connection type to 'Stepped'. The next thing you could do is within NodeWindowGUI method, comment out OnNodeGUI and the few lines just after that regarding ITaskAssignable between BeginVertical and EndVertical. I can't really tell you exact lines since I've changed things.
    I dont think there is much else to change beyond those, to make them more compact.
    Cheers
     
  45. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    Version 1.5.3 is live on the Asset Store!
    Make sure to read the change log provided in the Asset Store as I have't yet have time to update the online documentation. The approval was rather fast :)

    Cheers
     
  46. desyashasyi

    desyashasyi

    Joined:
    Nov 22, 2012
    Posts:
    73
    Hii Nuverian,
    Thank you for the update. Now i can try to create speak based on string lists. However, after i updated to NC 1.5.2, i fund many error i.e., done speaking() method. How to solve?

    nc3.png
    nc4.png

    There are some missing scripts

    nc6.png

    nc7.png

    Thanks.
     

    Attached Files:

    • NC5.png
      NC5.png
      File size:
      124.9 KB
      Views:
      840
    Last edited: Jul 25, 2014
  47. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    Hello,
    Please always remove the previous installation (folder) and reimport NodeCanvas anew. I can't stress this enough :)
    Please do so and restart Unity.
    Regarding the DoneSpeaking(), it has simply changed to Continue()

    EDIT--
    Regarding the Playmaker actions, make sure you unzip the included NodeCanvas_Playmaker.zip again as you did in the first time. Then reload Unity :)
     
  48. desyashasyi

    desyashasyi

    Joined:
    Nov 22, 2012
    Posts:
    73
    OK Thanks, I will try. About Playmaker, yes i forgot to extract playmaker action :). I was edited my post, Sorry :)
     
  49. desyashasyi

    desyashasyi

    Joined:
    Nov 22, 2012
    Posts:
    73
    I was tried two ways:
    1. As your suggestion, i removed node canvas folder. Then I restarted unity and i imported NC 1.5.3
    2. I removed previous NC. I uninstalled unity and then reinstalled unity 4.5.2. But i still getting this warning.

    NC8.png
     
  50. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    Hello,
    I suppose you didnt save your scene the first time, when things were not yet imported correctly right?
    What are the the scripts that you are missing? Are these some custom scripts? Are they in the project? From the sreen you've posted couple of posts before, it seems like it's the Playmaker scripts. Are they in project?

    Thanks