Search Unity

Behavior Designer - Behavior Trees for Everyone

Discussion in 'Assets and Asset Store' started by opsive, Feb 10, 2014.

  1. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    Behavior Designer 1.3 has been submitted! This version has a ton of changes and new features. As an example, here's a screenshot of the diff between version 1.2.7 of BehaviorManager.cs and version 1.3:
    BehaviorManagerDiff.PNG
    If you purchased Behavior Designer via opsive.com you should have already received an email with the download link. In this post I am going to go through some of the highlights of this release. For the full change list, take a look
    this post on the Opsive forums.

    Conditional Aborts
    This is the major feature that I was hinting at earlier. It is very similar to Observer Aborts in Unreal Engine 4's behavior tree implementation. Conditional aborts allow your behavior tree to dynamically respond to changes without having to clutter your behavior tree with many Interrupt/Perform Interrupt tasks. Most behavior tree implementations reevaluate the entire tree every tick. Conditional aborts are an optimization to prevent having to rerun the entire tree. More information on this feature can be found here, As an example of the power of conditional aborts, here's a picture of a behavior tree from the CTF sample project before:


    CTFBefore.PNG

    And after:

    CTFAfter.PNG

    Global Variables
    Shared variables are now able to be global - meaning any task within any behavior tree can see the same variable. This is good for sharing information between behavior trees. More information can be found here.

    GlobalVariableSelection.png

    Custom Shared Variables
    You can now create your own shared variable. Previous Behavior Designer versions relied on an enum within the editor dll to specify a shared variable so you weren't able to derive from SharedVariable and have the type show up in the variables drop down box. Information on the functions that you need to implement can be found here.

    CustomVariables.png
    Continued in next post (can only upload a max of 5 images)...
     
    Last edited: Jun 19, 2014
  2. RyuK

    RyuK

    Joined:
    Feb 12, 2014
    Posts:
    55
    Congrats on v1.3!

    With v1.3a and Unity 4.5.1, I encountered a strange behavior. I put a Start FSM task in an external behavior tree and set a gameobject with 2 Playmaker FSMs in the scene as the Playmaker Gameobject of that task. Then I saved the scene and reload it, and the gameobject is missing (resets to None) in the Playmaker Gameobject property of that task. Other properties such as Start Event Name are saved, but not the gameobject. The gameobject is not saved as a prefab, just exists in the hierarchy from the beginning. If I don't reload or close Unity it works as expected when I hit the play button. Is it the nature of .asset files?
     
  3. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    Grid Background
    I have added a grid background for those of you who require things to be precisely aligned. The the preferences there is an option if you want to snap your task to the grid (on by default).

    grid.PNG

    Compact Mode
    This feature has been requested for awhile and it is finally in version 1.3. You can now enable compact mode for the graph which will basically remove the icons.

    compact.PNG

    Exposed External Behavior Tree field on the Behavior Tree component
    Starting with version 1.2 (or shortly after) you could specify an external behavior tree to be loaded from script. To do this you would assign the externalBehavior variable on the behavior tree before the tree was enabled (doc link). This field has now been exposed so you can assign the tree without having to be running the game.

    external.PNG

    Added history buttons on the top of the window
    These buttons allow for quick navigation between behavior trees that have been selected

    history.PNG
    PlayMaker integration improvements:
    • StartFSM can now synchronize variables
    • StartFSM has the option of returning success immediately
    • Added Stop FSM and Send Event tasks
    • Added Start and Stop Behavior Tree actions
    uScript integration improvements:
    • StartGraph has the option of returning success immediately
    • Added Start and Stop Behavior Tree nodes

    The features listed above are just the highlights of this release. To see the full change log take a look at this post.
     
  4. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    @RyuK

    Oh, I see now.. you post about a 1.3 bug after I submit :)

    Actually I think that's expected functionality. The GameObject that you are pointing to is within the scene, correct? External behavior trees cannot point to objects within the scene. This is similar to prefabs not being able to reference objects within the scene.
     
  5. RyuK

    RyuK

    Joined:
    Feb 12, 2014
    Posts:
    55
    Yeah it's in the scene, thank you for clarification! If I save the gameobject in a prefab it seems to persist in the Playmaker gameobject property, but then it doesn't give me the expected result for some reason... I'll examine it further :)
     
  6. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    In your situation I recommend taking a look at the InheritedField attribute. The RTS sample project has an example of its use but its perfect for situations where you want to reference a scene object from an external behavior tree.
     
  7. RyuK

    RyuK

    Joined:
    Feb 12, 2014
    Posts:
    55
    Thank you, I checked out the RTS sample, in its Attack Strategy, the Set Target task sets target object into the Target variable, then AttackBehaviorTreeReference gets it via its InheritedField and passes it to actions such as Fire Projectile that has a variable with the same name and the InheritedField attribute, right? Is it inherited only when the variable name matches?

    In my case, what I'm supposed to do is probably to extend/override Assets/Behavior Designer/Third Party/PlayMaker/Tasks/StartFSM.cs (BehaviorDesigner.Runtime.Tasks.PlayMaker.StartFSM class) to use an InheritedField gameobject as its playmakerGameObject property, is it correct? I can do
    Code (csharp):
    1. public override void OnAwake() {
    2.     playMakerGameObject = GameObject.Find("Target Name");
    3.     base.OnAwake();
    4. }
    in the extended class, but I'd like to construct it in a more elegant, non-hard-scripted way.
     
    Last edited: Jun 19, 2014
  8. chelnok

    chelnok

    Joined:
    Jul 2, 2012
    Posts:
    680
    Hi @opsive, i was going to start to create my own trees today (been only testing examples) but i see there is 1.3 with conditional aborts.. in your case, how long it usually takes the Asset store to approve new version? And how about trees in Movement pack, are you planning to update the trees to use conditional aborts?
     
  9. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    @RyuK -

    Yes, the fields need to have the same name (and type) in order for InheritedField to work correctly. In your case I would subclass StartFSM and create your own PlayMaker GameObject that is inherited. Something like..

    Code (csharp):
    1.  
    2. public class StartFSMInherited : StartFSM
    3. {
    4.    [InheritedField]
    5.    public GameObject inheritedPlayMakerGameObject;
    6.  
    7.    public override void OnAwake()
    8.    {
    9.        playMakerGameObject = inheritedPlayMakerGameObject;
    10.        base.OnAwake();
    11.    }
    12. }
    13.  
    This requires the least amount of modification, doesn't rely on hard coded values, and will receive any updates to StartFSM.

    @chelnok -

    Lately it seems like it has been a day or two so I am hopeful that the update will go out before the weekend. I submitted it yesterday at about 6pm EST. The trees within the Movement Pack really only contain one task so there isn't anything to update. I have updated the sample projects though and am waiting for the Asset Store version to go live before I switch those out.
     
  10. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    Well that was really fast.. version 1.3 has been approved on the Asset Store!
     
  11. electroflame

    electroflame

    Joined:
    May 7, 2014
    Posts:
    177
    Congrats on 1.3! Been using the beta build for a while and it's been really awesome -- a huge step forward from 1.2.

    Great work!
     
  12. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    Thank you! I agree in that 1.3 is a huge step forward. I don't know how I am going to top it with 1.4 :)
     
  13. angelodelvecchio

    angelodelvecchio

    Joined:
    Nov 15, 2012
    Posts:
    170
    Hello ! this asset is wonderful !.

    is possible to use unityscript ?

    I mean, to comunicate with behavior tree ? change its variables in "variables" and other things ?

    Many thanks
     
  14. angelodelvecchio

    angelodelvecchio

    Joined:
    Nov 15, 2012
    Posts:
    170
    example,

    in the minigauntlet example, i exchanged the TaskTriggerSelector.cs to a unityscript version:

    #pragma strict

    //using BehaviorDesigner.Runtime.Tasks

    class TaskTriggerSelector_JS extends BehaviorDesigner.Runtime.Tasks.Composite
    {

    var nextTaskIndex: int = 0;
    enum TaskTriggerType { Idle, Jump, SphereCollision, PlaySound }

    override function CurrentChildIndex()
    {

    // The next task index will be 0 unless a collision or trigger event has occurred
    return nextTaskIndex;

    }
    override function OnChildExecuted( childStatus: BehaviorDesigner.Runtime.Tasks.TaskStatus )
    {
    // Set the next task index back to 0 immediately after the child has executed to prevent a non-idle task from running multiple tiles
    nextTaskIndex = 0;
    }

    override function OnTriggerEnter( other: Collider )
    {
    /*
    var triggerType: TriggerType = null;
    //if ( (triggerType = other.GetComponent<TriggerType>() ) != null)
    triggerType = other.GetComponent( TriggerType );
    if ( triggerType != null )
    {

    //nextTaskIndex = triggerType.triggerType;

    }
    */

    nextTaskIndex = 1;
    }

    }

    and I cant get it to work, i receive a DICTIONARY KEY NOT OR SOMETIMES:

    NullReferenceException: Object reference not set to an instance of an object
    BehaviorDesigner.Runtime.BehaviorManager.addToTaskList (BehaviorDesigner.Runtime.BehaviorTree behaviorTree, BehaviorDesigner.Runtime.Tasks.Task task, System.Boolean& hasExternalBehavior, BehaviorDesigner.Runtime.TaskAddData data)
    BehaviorDesigner.Runtime.BehaviorManager.addToTaskList (BehaviorDesigner.Runtime.BehaviorTree behaviorTree, BehaviorDesigner.Runtime.Tasks.Task task, System.Boolean& hasExternalBehavior, BehaviorDesigner.Runtime.TaskAddData data)
    BehaviorDesigner.Runtime.BehaviorManager.enableBehavior (BehaviorDesigner.Runtime.Behavior behavior)
    BehaviorDesigner.Runtime.Behavior.EnableBehavior ()
    BehaviorDesigner.Runtime.Behavior.Start ()



    OR

    eyNotFoundException: The given key was not present in the dictionary.
    System.Collections.Generic.Dictionary`2[System.String,System.Object].get_Item (System.String key) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:150)
    BehaviorDesigner.Runtime.DeserializeJSON.DeserializeSharedVariable (System.Collections.Generic.Dictionary`2 dict, BehaviorDesigner.Runtime.BehaviorSource behaviorSource)
    BehaviorDesigner.Runtime.DeserializeJSON.ValueToObject (BehaviorDesigner.Runtime.Tasks.Task task, System.Type type, System.Object obj, BehaviorDesigner.Runtime.BehaviorSource behaviorSource, System.Collections.Generic.Dictionary`2& taskIDs)
    BehaviorDesigner.Runtime.DeserializeJSON.DeserializeObject (BehaviorDesigner.Runtime.Tasks.Task task, System.Object obj, System.Collections.Generic.Dictionary`2 dict, BehaviorDesigner.Runtime.BehaviorSource behaviorSource, System.Collections.Generic.Dictionary`2& taskIDs)
    BehaviorDesigner.Runtime.DeserializeJSON.DeserializeTask (BehaviorDesigner.Runtime.BehaviorSource behaviorSource, System.Collections.Generic.Dictionary`2 dict, System.Collections.Generic.Dictionary`2& IDtoTask, System.Collections.Generic.Dictionary`2& taskIDs)
    BehaviorDesigner.Runtime.DeserializeJSON.DeserializeTask (BehaviorDesigner.Runtime.BehaviorSource behaviorSource, System.Collections.Generic.Dictionary`2 dict, System.Collections.Generic.Dictionary`2& IDtoTask, System.Collections.Generic.Dictionary`2& taskIDs)
    BehaviorDesigner.Runtime.DeserializeJSON.DeserializeTask (BehaviorDesigner.Runtime.BehaviorSource behaviorSource, System.Collections.Generic.Dictionary`2 dict, System.Collections.Generic.Dictionary`2& IDtoTask, System.Collections.Generic.Dictionary`2& taskIDs)
    BehaviorDesigner.Runtime.DeserializeJSON.Deserialize (BehaviorDesigner.Runtime.BehaviorSource behaviorSource)
    BehaviorDesigner.Runtime.BehaviorSource.CheckForJSONSerialization (Boolean force)
    BehaviorDesigner.Editor.GraphDesigner.Load (BehaviorDesigner.Runtime.BehaviorSource behaviorSource, Boolean loadPrevBehavior, Vector2 nodePosition)
    BehaviorDesigner.Editor.BehaviorDesignerWindow.LoadBehavior (BehaviorDesigner.Runtime.BehaviorSource behaviorSource, Boolean loadPrevBehavior, Boolean firstLoad, Boolean reposition, Boolean inspectorLoad)
    BehaviorDesigner.Editor.BehaviorDesignerWindow.UpdateTree (Boolean firstLoad)
    BehaviorDesigner.Editor.BehaviorDesignerWindow.OnSelectionChange ()
    UnityEditor.EditorApplication.Internal_CallHierarchyWindowHasChanged () (at C:/BuildAgent/work/aeedb04a1292f85a/artifacts/EditorGenerated/EditorApplication.cs:258)


    sorry to insist, but i have a great 3rd person framework working good and all in unityscript,

    Many thanks
     
  15. Seith

    Seith

    Joined:
    Nov 3, 2012
    Posts:
    755
    I have another silly question. I'm trying to stop a character's behavior tree by doing a:

    Code (CSharp):
    1. myTransform.GetComponent<BehaviorTree>().DisableBehavior(false);
    But that doesn't seem to work as I get an error: Type `BehaviorDesigner.Runtime.BehaviorTree' does not contain a definition for `DisableBehavior' and no extension method `DisableBehavior' of type `BehaviorDesigner.Runtime.BehaviorTree' could be found (are you missing a... etc...
     
  16. Siberdt

    Siberdt

    Joined:
    Dec 15, 2009
    Posts:
    59
    Oh, Justin, thanks a lot for the grid pattern :)
    And now we can paste variable names from the clipboard! Hurrah!

    Hmm... how can I work with global variables through the code?
    behaviorTree.GetVariable(_name) not works for globals.
     
    Last edited: Jun 20, 2014
  17. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    @angelodelvecchio -

    It's great to hear that you're enjoying Behavior Designer. You can definitely use UnityScript - did you change the directory structure?

    @Seith -

    That single line of code looks good. Two questions:

    1. Previous versions of Behavior Designer had a lowercase 'd' making the method disableBehavior instead of DisableBehavior. Are you using version 1.3 of Behavior Designer?
    2. Are you including the BehaviorDesigner.Runtime namespace?

    I just created this small script and it didn't complain:
    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using BehaviorDesigner.Runtime;
    4. public class InstantiateTrees : MonoBehaviour {
    5.    void Start () {
    6.   transform.GetComponent<BehaviorTree>().DisableBehavior(false);
    7.    }
    8. }
    9.  
    @Paul Siberdt -

    Yeah, the grid really helps.. It's tough to go back to the non-grid version. In terms of accessing the GlobalVariables, you get them by:

    Code (csharp):
    1.  
    2. GlobalVariables.Instance.GetVariable("Name");
    3.  
    It looks like I forgot to add this to the documentation.
     
  18. Siberdt

    Siberdt

    Joined:
    Dec 15, 2009
    Posts:
    59
    Thanks.

    Would be great if you add the ability to set up the color of each node, it would be useful for logic true/false triggers and etc.
    Oh, there is one more suggestion, a sort of decoration zone-type object. Take a look on screen of WorldMachine editor. This color areas help to visually read really wast trees.

    Here is the example:
     
  19. angelodelvecchio

    angelodelvecchio

    Joined:
    Nov 15, 2012
    Posts:
    170
    Code (csharp):
    1.  
    2. GlobalVariables.Instance.GetVariable("Name");
    3.  
    but please, how i can make this in unityscript ?

    can you please post a sample project in unityscript ?


    Many thanks







    FELLOWS, THIS IS ONE OF THE BEST INVESTMENTs I DID IN UNITY ASSETS.

    MANY THANKS!
     
    Last edited: Jun 21, 2014
  20. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    @Paul Siberdt -

    I had task colors already written down so it's a good sign that my feature request list matches up with something that somebody actually wants. In terms of the WorldMachine colored background, I didn't have that one written down but I definitely don't mind prototyping it out to see if it is something that would be useful. I'll post about it here when I've made some progress.

    @angelodelvecchio -

    I appreciate your enthusiasm :)

    So this just about pushed my UnityScript abilities but I have attached a very simple tree that has one task in UnityScript and another MonoBehaviour object using UnityScript that will output a global variable value.

    First off, the task simply assigns a value to a shared variable:

    Code (csharp):
    1.  
    2. #pragma strict
    3.  
    4. class SetSharedVariable extends BehaviorDesigner.Runtime.Tasks.Action
    5. {
    6.   var myInt : BehaviorDesigner.Runtime.SharedInt;
    7.  
    8.   function OnStart()
    9.   {
    10.   Debug.Log("Task Start");
    11.   }
    12.  
    13.   function OnUpdate()
    14.   {
    15.   myInt.Value = 42;
    16.   return BehaviorDesigner.Runtime.Tasks.TaskStatus.Success;
    17.   }
    18. }
    19.  
    Then once the tree gets done executing that value will be printed to the console:
    Code (csharp):
    1.  
    2. #pragma strict
    3.  
    4. class OutputValueWhenDone extends MonoBehaviour
    5. {
    6.   var behaviorTree : BehaviorDesigner.Runtime.BehaviorTree;
    7.  
    8.   function Update () {
    9.   if (behaviorTree.ExecutionStatus != BehaviorDesigner.Runtime.Tasks.TaskStatus.Running) {
    10.   Debug.Log("Assigned Variable: " + (BehaviorDesigner.Runtime.GlobalVariables.Instance.GetVariable("MyInt") as BehaviorDesigner.Runtime.SharedInt).Value);
    11.   enabled = false;
    12.   }
    13.   }
    14. }
    15.  
    Before you import make sure you change the directory structure as I mentioned earlier so Behavior Designer will find the UnityScript tasks.
     

    Attached Files:

  21. Seith

    Seith

    Joined:
    Nov 3, 2012
    Posts:
    755
    @Opsive: I'm having a hard time starting a couroutine within a task using:

    Code (CSharp):
    1. StartCoroutine("DoStartConfusion", waitTime);
    And I get this weird error message:

    NullReferenceException: Object reference not set to an instance of an object
    BehaviorDesigner.Runtime.Behavior.StartTaskCoroutine (BehaviorDesigner.Runtime.Tasks.Task task, System.String methodName, System.Object value)
    BehaviorDesigner.Runtime.Tasks.Task.StartCoroutine (System.String methodName, System.Object value)
    TaskConfused.StartConfusion (Single waitTime) (at Assets/Scripts/AI/Tasks/TaskConfused.cs:50)
    (...)


    I looked at the documentation page but found nothing regarding coroutines so I'm a bit at a loss here...
     
  22. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    Is DoStartConfusion a private method? The coroutine system was only looking for public methods so that's probably why you are getting the error. I just changed it so it will look for private methods as well - I can send you a new version or you can just make it public for now.
     
  23. Seith

    Seith

    Joined:
    Nov 3, 2012
    Posts:
    755
    Yes, that was exactly that; the method was private; it works when I make the IEnumerator public. It's great to know it'll work for private methods too in the next version. Thanks Justin!
     
  24. Seith

    Seith

    Joined:
    Nov 3, 2012
    Posts:
    755
    I have another question: is it possible to call a task function from a monobehavior script? I tried:

    Code (CSharp):
    1. actorTransform.GetComponent<BehaviorTree>().FindTask("TaskConfused").CancelConfusion();
    But I get an error message:

    error CS1061: Type `BehaviorDesigner.Runtime.BehaviorTree' does not contain a definition for `FindTask' and no extension method `FindTask' of type `BehaviorDesigner.Runtime.BehaviorTree' could be found (are you missing a using directive or an assembly reference?)

    Edit:
    I tried "GetTask" but it doesn't seem to work either...
     
  25. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    The FindTask method was a hypothetical example of what I would have to do in order to allow you to be able to see the value of a variable that isn't a shared variable. You keep coming up with use cases for it though so I will add it to the next version.

    In the meantime, you'll have to manually set a reference to the task within the component:

    Code (csharp):
    1.  
    2. public class MyComponent : MonoBehaviour
    3. {
    4.    public TaskConfused task;
    5.  
    6.    public void CancelConfusion()
    7.    {
    8.       task.CancelConfusion();
    9.    }
    10. }
    11.  
    Code (csharp):
    1.  
    2. public class TaskConfused : Action
    3. {
    4.    public override void OnAwake()
    5.    {
    6.       gameObject.GetComponent<MyComponent>().task = this;
    7.    }
    8. }
    9.  
     
  26. Seith

    Seith

    Joined:
    Nov 3, 2012
    Posts:
    755
    Oh I see! So I'll do that for now, thank you very much!

    (I have a diploma in "using-APIs-in-unforeseen-ways" :) )
     
  27. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    hehe, no worries. It should be quick to do.

    I'm thinking that I will have two different versions of the API: one that searches based on the task type, and another that searches based on the task name. There will be versions that return both a single task and an array of tasks (if you are just using the single task version it will return the task based on a depth first search). Obviously you will want to cache the results and won't want to call these methods every frame since it will have to search the tree.
     
  28. Seith

    Seith

    Joined:
    Nov 3, 2012
    Posts:
    755
    That sounds perfect!
     
  29. angelodelvecchio

    angelodelvecchio

    Joined:
    Nov 15, 2012
    Posts:
    170
    Please I dont want to be a pain in *(#%*)23, i dont know if this is relative to your asset, but i am on unityscript and I found this in a cs script:


    [TaskDescription("The interrupt task will stop all child tasks from running if it is interrupted. The interruption can be triggered by the perform interruption task. " +
    "The interrupt task will keep running its child until this interruption is called. If no interruption happens and the child task completed its " +
    "execution the interrupt task will return the value assigned by the child task.")]
    [HelpURL("http://www.opsive.com/assets/BehaviorDesigner/documentation.php?id=35")]
    [TaskIcon("{SkinColor}InterruptIcon.png")]


    and this

    [TaskCategory("MiniGauntlet")]
    [TaskDescription("A composite task that will choose its child based on the latest collision/trigger event.")]

    Please, how i can input this in unityscript ? i would like ot make my TASKS list organized,

    *** sorry if this is off-topic, i am learning unity

    MANY THANKS
     
  30. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    Those are called attributes and it's more of a general topic. However, you can see a few different examples of other attributes in Unity here. You should be able to add a '@' in front of the name and remove the brackets:

    Code (csharp):
    1.  
    2. @TaskIcon("{SkinColor}InterruptIcon.png")
    3.  
     
  31. angelodelvecchio

    angelodelvecchio

    Joined:
    Nov 15, 2012
    Posts:
    170
    Sorry for taking your time to answer things not related to your asset, i will try to research more next time ;)

    I am making an entire 3rd person controller using your great asset, and more one time folks: This worth every penny, I am even not using other similar solutions anymore, just this great pack, please if you can, release other packs for different situations, for sure i will be your first costumer,

    Many thanks
     
  32. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    No worries, I'm happy to help and I am really happy to hear that you're enjoying it. When you say more packs - do you mean more packs such as the Movement Pack or completely new assets? If you're talking about another pack similar to the Movement Pack, what would you like to see? In terms of other assets, we've been working on those as well :)
     
  33. KimNulbo

    KimNulbo

    Joined:
    Jun 25, 2014
    Posts:
    8
    hi, I have a question.
    I Use externalBehavior
    and i use
    _Behavior = gameObject.AddComponent<BehaviorTree>();
    _Behavior.externalBehavior = (BehaviorDesigner.Runtime.ExternalBehavior)Object.Instantiate(Resources.Load("MoveBehavior"));
    _Behavior.startWhenEnabled = true;

    Worked in this way.
    in Editor looks good
    but in Android Device Fail Message is (The behavior "Behavior" on GameObject "unit" contains no root task. This behavior will be disabled)

    What should I do?
     
  34. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    In version 1.3 there was a bug with external behavior trees not being properly serialized on startup. You can fix it by extracting the runtime source code and adding the following to BehaviorManager.cs:
    Code (csharp):
    1.  
    2.   if (behavior.externalBehavior != null) {
    3.      behavior.externalBehavior.BehaviorSource.CheckForSerialization(true, false);
    4.   }
    5.  
    Add this to line 171, right before:
    Code (csharp):
    1.  
    2. var rootTask = (behavior.externalBehavior != null ? behavior.externalBehavior.BehaviorSource.RootTask : behavior.GetBehaviorSource().RootTask);
    3.  
    I have made a few other relatively minor fixes to version 1.3.1 and plan on submitting an update either today or tomorrow.
     
  35. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    Behavior Designer 1.3.1 was submitted to this Asset Store this morning. If you purchased via opsive.com you should have already received an email with the download link. For the full change list take a look at this post. Some of the highlights:
    • Added Behavior.FindTask and Behavior.FindTaskWithName
    • Added Assets/Create/Behavior Designer context menu – can create external behavior trees, actions, and conditional tasks
    • Added Component/Behavior Designer context menu
    • Deserialize the external behavior tree when starting up if necessary
     
  36. angelodelvecchio

    angelodelvecchio

    Joined:
    Nov 15, 2012
    Posts:
    170
    Sorry to bother, here it go again noob questions,

    i simply cant make tasks share and set and get shared variables, in the samples it works good with csharp but i cant make it work with unityscript, it will bother you too much to show me how to make
    the tasks in unityscript to access and get/set globalvariables ? shared variables is the same thing ? nothing works here with unityscript,

    everything that i tried returns me: Object reference not set to an instance of an object

    Many thanks
     
  37. angelodelvecchio

    angelodelvecchio

    Joined:
    Nov 15, 2012
    Posts:
    170
    AVAST REPORTED AS HARMFUL WEBSITE
     
  38. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    I reported that post from dsangdhw as spam, the mods will remove it shortly.

    In terms of your question, here's a tree that assigns a local SharedVariable and outputs it both from a task and a regular MonoBehaviour component. Did you try out the script from before with the global variable example? This is similar to my other unityscript example except it uses local instead of global variables.
     

    Attached Files:

  39. angelodelvecchio

    angelodelvecchio

    Joined:
    Nov 15, 2012
    Posts:
    170
    thanks for answering, this is what I get:

    BCE0022: Cannot convert 'int' to 'BehaviorDesigner.Runtime.SharedInt'.
     
  40. angelodelvecchio

    angelodelvecchio

    Joined:
    Nov 15, 2012
    Posts:
    170
    this happens when I do: myInt = 50;


    ***** OH Please, sorry to waste your time, myInt.Value <- this was missing.

    Many thanks
     
  41. TheLordDave

    TheLordDave

    Joined:
    Mar 2, 2014
    Posts:
    28
    Im having an issue with the latest version. If i load an existing behaviour tree and apply it, my sequence nodes are running as if they are parallel nodes.

    Also if i spawn another pawn instance using the same behaviour tree, only the latest spawned instance's tree runs.

    any ideas what could be wrong?
     
  42. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    If you had multiple prefabs/external behavior trees there was a bug in version 1.3 that caused the task instances to all be the same. I have fixed this with version 1.3.1 which is still waiting for approval. It sounds like this could be related (though sequence tasks acting like parallel tasks are new to me).

    You've sent me an email before with your invoice number, correct? Do you mind sending me another email so I can send you the latest to try out?
     
  43. TheLordDave

    TheLordDave

    Joined:
    Mar 2, 2014
    Posts:
    28
    sure i will send it over again. It looks like it is not actually running the tasks like a parallel selector after all. It seems it is the same bug you mentioned.

    The second instance is picking up the first instances tree half way through which checks a local variable. This variable in the new instance is not set so unity bugs out and crashes the first instance. Which makes it appear all tasks are running parallel when actualy it is a single tree.

    I will send the invoice number now.

    Cheers
    Dave
     
  44. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    It took a little bit but version 1.3.1 has been approved on the Asset Store. The full change list is located here. @Seith, this has your FindTask and FindTaskWithName functions.
     
  45. chelnok

    chelnok

    Joined:
    Jul 2, 2012
    Posts:
    680
    Thanks! Latest videos are really good and informative. Conditional aborts are absolutely great. However, what comes to visual debugging, i think it would be nice if one could see there is something happening in background. Perhaps circular red arrow instead of current red X ..or something.
     
  46. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    Great to hear that conditional aborts have been useful!

    In terms of having some type of indicator on the task, that's a good idea. I will be submitting version 1.3.2 next week and then will add it for 1.3.3. I am also planning on having some type of icon on the composite task to indicate that it has an abort type set.
     
  47. EvilAlfredo

    EvilAlfredo

    Joined:
    Aug 11, 2012
    Posts:
    7
    So, after updating to 1.3.1, I just ran into 270(!) errors, all along the lines of "Assets/Behavior Designer/Runtime/Variables/SharedTransformList.cs(7,40): error CS0246: The type or namespace name `SharedVariable' could not be found. Are you missing a using directive or an assembly reference?"
    I have tried reimporting the behavior designer into my project, with no luck. At first it was only happening with the Dialogue System third party support files, but then it happened with everything else after hitting play.
    Any idea on how to get around this? A quick response would be greatly appreciated, as I have to get this working by the end of the week. (Sorry to be blunt, I'm just in a bit of a panic with deadlines coming up.)
     
  48. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    No problem. The SharedVariable class is located within the BehaviorDesignerRuntime dll - does that DLL exist? Reimporting should have worked. Make sure you completely delete the /Behavior Designer folder before you import. If you have extracted the runtime source code you'll need to delete /Plugins/Behavior Designer as well.
     
  49. EvilAlfredo

    EvilAlfredo

    Joined:
    Aug 11, 2012
    Posts:
    7
    I think I found the problem. After reimporting again, I found in the console that it was deleting assemblies that weren't for Unity 4.5. However, since Behavior Designer relies on those it seems, I had to turn off the option that "Deleted Outdated Registries", and it seems to have fixed it.
    The only problem now is that it appears to be coming up with a prompt to delete these registries every time I test my project, which interrupts work flow quite a bit; especially if I accidentally select the "Yes" option.
     
  50. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    Was it deleting a BehaviorDesigner* assembly? Even with version 4.5 you should be able to select yes to the prompt that asks you if you want to delete the unnecessary assemblies. The same assemblies for version 4.3 work for version 4.5. Before you do this though you have to make sure the /Behavior Designer directory is completely removed otherwise you'll get errors.