Search Unity

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

Behavior Designer - Behavior Trees for Everyone

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

  1. tspk91

    tspk91

    Joined:
    Nov 19, 2014
    Posts:
    131
    I feel that stacked conditionals might have the same problem as conditional evaluators: you cannot see what conditionals are inside from the graph view. It would be nice if nodes could have a (collapsable?) section under the main box, where such info could be shown automatically.

    My workaround for this is renaming the nodes to their internal conditional task, or using comments, but these can be difficult to mantain and easily mixed up.
     
  2. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    That is a good point, and I've been trying to figure out a nice way to display it. In version 2 I have the node list each task within the actual graph, but the nodes in version 1 are a different style so that doesn't make it as easy. Maybe I could draw it on the opposite side of the comment?
     
    PatrickMobX likes this.
  3. SoftwareGeezers

    SoftwareGeezers

    Joined:
    Jun 22, 2013
    Posts:
    902
    Just come across this researching flocking options for A* PathFinding. I'm developing a multithreaded engine on top of Unity somewhat akin to the new Entity system that eschews the classic Mono script spaghetti in favour of large controller scripts that run through lists of objects for processing.

    As such, I can't use Assets that take control of gameobject's rigidbodies or transforms and just want to plug method calls in. How does Behaviour Designer integrate with the rest of the code? Can I easily create a bunch of behaviours that call my movement scripts for me to process when appropriate? And do sensor tests require transforms and layers or can I provide my own tests/references (own script vectors)?
     
  4. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    Thanks for taking a look at Behavior Designer.

    The Behavior Tree component is attached to a GameObject and this holds your behavior tree structure (or external trees, but those are eventually consumed by the behavior tree component). Other than that there aren't any requirements and it just depends on what tasks you are using. For example, if you don't want to use the rigidbody or transforms then you don't use the tasks which affect those components.

    Yes, you can create new tasks which have a very similar to the MonoBehaviour API: https://opsive.com/support/documentation/behavior-designer/writing-a-new-conditional-task/

    You are referring to the Movement Pack's Can See Object task, correct? That task does use the agent's transform, but you'd be able to modify it easily to provide your own inputs.
     
  5. SoftwareGeezers

    SoftwareGeezers

    Joined:
    Jun 22, 2013
    Posts:
    902
    Okay. Having a very quick nose, an Action class is something that can be connected within the tree and is extensible with custom action scripts?
     
  6. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    Yes, the action class is responsible for changing the world state in some way. It can be inherited and then you can provide your or functionality. This video gives a good overview of the behavior tree structure:

     
  7. UnityRocksAlt

    UnityRocksAlt

    Joined:
    Dec 28, 2015
    Posts:
    157
    No overload method 'WithinSight' takes '11' arguments
    Search.cs:88 column 52
     
  8. UnityRocksAlt

    UnityRocksAlt

    Joined:
    Dec 28, 2015
    Posts:
    157
    Fixed it, found other usages, realised debugRay.Value was extra parameter. Removed that.
     
  9. UnityRocksAlt

    UnityRocksAlt

    Joined:
    Dec 28, 2015
    Posts:
    157
    Fixed the code for Sensor Toolkit Integration.


    No overload for method `Clear' takes `0' arguments
    [CompilerError] Type `UnityEngine.GameObject[]' does not contain a definition for `Add' and no extension method `Add' of type `UnityEngine.GameObject[]' could be found. Are you missing `Sirenix.OdinInspector.Editor' using directive?
    Compiler Error at Assets/Behavior Designer/Integrations/SensorToolkit/SensorSetIgnoreList.cs:37 column 35
    35: sensor.IgnoreList.Clear();
    36: for (var i = 0; i < length; i++) {
    -->37: sensor.IgnoreList.Add(ignoreList.Value as UnityEngine.GameObject);
    38: }
    39: return TaskStatus.Success;

    Type `UnityEngine.GameObject[]' does not contain a definition for `Add' and no extension method `Add' of type `UnityEngine.GameObject[]' could be found. Are you missing `Sirenix.OdinInspector.Editor' using directive?
    [CompilerError] No overload for method `Clear' takes `1' arguments
    Compiler Error at Assets/Behavior Designer/Integrations/SensorToolkit/SensorSetIgnoreList.cs:35 column 31
    34: var length = ignoreList.Value.Count;
    -->35: sensor.IgnoreList.Clear(ignoreList.Value);
    36: for (var i = 0; i < length; i++) {
    37: sensor.IgnoreList.Add(ignoreList.Value as UnityEngine.GameObject);
     
    Last edited: Jul 26, 2021
    hopeful likes this.
  10. UnityRocksAlt

    UnityRocksAlt

    Joined:
    Dec 28, 2015
    Posts:
    157
    I fixed that to this, replace from line 35 (sensor.IgnoreList.Clear()) to line 38 (line before return TaskStatus.Success):

    Array.Clear(sensor.IgnoreList,0,length);
    List<GameObject> arrayToList = new List<GameObject>(length);
    for (var i = 0; i < length; i++) {
    arrayToList.Add(ignoreList.Value);
    sensor.IgnoreList = arrayToList;
    }
     
    hopeful likes this.
  11. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    Hello,

    For support can you post on the the opsive forums at https://opsive.com/forum? This allows me to track each request better.

    Justin
     
  12. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    Version 1.7 of Behavior Designer has been released on the Opsive Store and is making its way to the Asset Store. You can see what has changed on this page.

    Version 1.7 contains three new tasks:

    NewTasks.png

    The Stacked Action and Stacked Conditional tasks allow you to add multiple conditional or action tasks to the same node. The Stacked Conditional task is especially useful for conditional aborts allowing you to reevaluate multiple tasks at the same time. The Cooldown task will wait the specified duration before returning the status of the child task.
     
  13. a363881055

    a363881055

    Joined:
    Jul 11, 2021
    Posts:
    2
    In FollowLeader,how to add follower dynamic?
     
  14. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    Hello,

    For support can you post on the the opsive forums at https://opsive.com/forum? This allows me to track each request better.

    Justin
     
  15. Kapteeni-Studios

    Kapteeni-Studios

    Joined:
    Apr 5, 2014
    Posts:
    39
  16. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    I would contact the Obfuscator developer to see if anything can be done. Behavior Designer is all C# in a managed environment so from that standpoint it shouldn't be a difficult use case.
     
    twobob and Kapteeni-Studios like this.
  17. dwatt-hollowworldgames

    dwatt-hollowworldgames

    Joined:
    Apr 26, 2019
    Posts:
    104
    How many agents can behaviour designer handle at the same time?
     
  18. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    That's a tough question as there are a ton of factors. I can say though that traversing the tree is fast. When there is a bottleneck it will generally be caused by something other than the tree traversal. I have easily gotten thousands of agents running at the same time when I am not concerned about other factors such as graphics or physics.
     
  19. dwatt-hollowworldgames

    dwatt-hollowworldgames

    Joined:
    Apr 26, 2019
    Posts:
    104
    cool ty that was the answer I was looking for.
     
  20. kotor

    kotor

    Joined:
    Dec 3, 2013
    Posts:
    140
    Is Behavior designer (Movement pack) compatible with TopDown engine from More Mountains ? I mean can I use Behaviors designer and movement pack with Topdown engine
     
  21. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    I haven't used Top Down Engine so I'm not sure how it is structured. If it has AI included and you want to use their AI there would likely be a conflict.
     
  22. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
  23. Disastorm

    Disastorm

    Joined:
    Jun 16, 2013
    Posts:
    132
    Hello, can you tell me what the Movement System's Cover Task is supposed to do?
    Isn't the idea of cover that you take cover from a target so they can't see you anymore?
    The Cover Task doesn't seem to have any kind of "target" to hide from.
     
  24. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    Hello,

    For support can you post on the the opsive forums at https://opsive.com/forum? This allows me to track each request better.

    Justin
     
  25. wechat_os_Qy0z_aF7Nfhquhava38GLxUWU

    wechat_os_Qy0z_aF7Nfhquhava38GLxUWU

    Joined:
    Dec 22, 2021
    Posts:
    56
    Can this plug-in be use for the MoreMountains Corgi Engine without writing any code?
     
  26. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    We don't have an integration with Corgi Engine and I don't have much experience with it but I do know that it's a good asset. I would expect that you can disable the AI in Corgi and then have the agent completely controlled with Behavior Designer. You can use the reflection tasks to call a Corgi method such as damage. Unfortunately though without more experience I am not sure if it'll take some custom code.
     
  27. PaperMouseGames

    PaperMouseGames

    Joined:
    Jul 31, 2018
    Posts:
    434
    Hello! Is there any kind of demo available for this? I'm very curious about it but I'd like to try it out first, thanks!
     
  28. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    I can create a build which allows for a limited number of tasks within your behavior tree for a demo - if you send an email to support@opsive.com I'll create the build and send you a link.
     
    PaperMouseGames likes this.
  29. kotor

    kotor

    Joined:
    Dec 3, 2013
    Posts:
    140
    I have created Condtional Task for Behavior tree. It seems the BT is running but the success and failure icons are not displayed as if nothing is running. Please advise
     
  30. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    Hello,

    For support can you post on the the opsive forums at https://opsive.com/forum? This allows me to track each request better.

    Justin
     
  31. Magic73

    Magic73

    Joined:
    Jun 23, 2015
    Posts:
    132
    Hi Justin,
    I have a question about this module.
    I wanted to know if the movement was consistent between the platforms. starting from the same scenario, a bot starts from point A, and must reach point B. will the movement be the same, and at the same time whether it is performing the task on a PC, on Android or on an iOS device?
    Is it conceivable to use this module, so in a multiplayer game I just have to time the start of an action, and then be sure that after X seconds the result on two devices is the same?
     
  32. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    I haven't tested that scenario but Behavior Designer doesn't do any actual pathfinding - it is up to the underlying pathfinding implementation to move the agent. Behavior Designer is responsible for telling where the agent should move, but not the actual movement. The movement is most commonly done by Unity's NavMesh or A* Pathfinding Project.
     
    Last edited: Aug 26, 2022
  33. mcmonk

    mcmonk

    Joined:
    Sep 22, 2014
    Posts:
    14
    Hey, i'm having some trouble adding external behaviour trees at runtime to a subclass of the BehaviorTreeReference class. When I try to fetch it via script via:

    behaviourTree.FindTask<BehaviorTreeReference>();
    behaviourTree.FindTaskWithName("Job list");

    I get null in both cases. It works fine if I try to get any other task in the behavior tree. I have also tried to subclass BehaviorTreeReference as was mentioned in some other posts but I simply can't get it to work. Do you have an example on how I can dynamically add external behaviour trees at runtime to a BehaviorTreeReference task at runtime?
     
  34. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    Hello,

    For support can you post on the the opsive forums at https://opsive.com/forum? This allows me to track each request better.

    Justin
     
  35. MyOwnGames

    MyOwnGames

    Joined:
    Jul 21, 2014
    Posts:
    25
    Hi Justin,
    I bought the Movement Pack for BD yesterday, but my invoice is still not recognized on www.opsive.com.
    I use the A* Pathfinding asset in my project, so I can't start working on it without the A* integration package.
    Thought it would be available this morning CET.
    Could I start working on it today? As great as they are, buying your assets and not be able to use them off the box is a bit frustrating...
    Thank you!
     
  36. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    Hello

    For invoice support please email support@opsive.com with your invoice number so I can take a look at the issue. Also, give the downloads page one more try as sometimes it takes a bit for the verification API to be able to find your invoice.

    Justin
     
    Last edited: Dec 14, 2022
  37. Wrymnn

    Wrymnn

    Joined:
    Sep 24, 2014
    Posts:
    373
    There is a nasty bug with setting variables via Behavior Tree Reference node

    I have a Behavior Tree asset, with "Attack Target" variable of type Entity (Monobehavior)
    upload_2022-12-20_22-0-34.png
    This tree has a node, Clear Targets, focus on two variables, List<SharedEntity> and SharedEntity
    upload_2022-12-20_21-58-39.png
    They point to the above declared "Attack Target" variable.

    Now I have another Behavior Tree, which has a Behavior Tree Reference node reference to the above tree. There is "Nearby Target" variable of type Entity.
    I linked it, so the first tree variable is replaced by this Nearby Enemy.
    upload_2022-12-20_21-59-10.png

    Now all works fine, except the List<SharedEntity> is not replaced correctly, but the SharedEntity variable is replaced:
    upload_2022-12-20_22-5-49.png
    You can see the "Targets" variable list has the original "Attack Target" variables linked, which should not even exist. The "Target" variable has the correct "Nearby Enemy" linked.
     

    Attached Files:

  38. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    Hello,

    For support can you post on the the opsive forums at https://opsive.com/forum? This allows me to track each request better. Make sure you are running the latest version and if you can attach your scene/external tree that would be helpful.

    Justin
     
  39. ml785

    ml785

    Joined:
    Dec 20, 2018
    Posts:
    119
    Hi, are there any tutorials or resources that use Behavior Designer for a racing style game?
     
  40. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    Hello - unfortunately I am not familiar with tutorials for the racing genre.
     
  41. mick129

    mick129

    Joined:
    Jun 19, 2013
    Posts:
    228
    Just out of curiosity, is there any plan to integrate this asset with RPG Builder?
    Having mobs casting abilities, taking damage etc.

    If no I was thinking about doing it myself and I was wondering if I would be allowed to sell the integration on the store (requiring the 2 dependencies).
     
  42. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    This is the first request that I've gotten but an integration with RPG Builder does seem like it makes sense. Unfortunately I don't think that I'll be able to add it anytime soon, which leads to..

    Yes, you definitely can. If you do end up selling it let me know and I'll help promote it where I can.
     
    mick129 likes this.
  43. mick129

    mick129

    Joined:
    Jun 19, 2013
    Posts:
    228
    Thank you for the quick reply!
    I have my release in February and will probably tackle this on March then :).

    Cheers!
     
    opsive likes this.
  44. sanctanox

    sanctanox

    Joined:
    Sep 22, 2022
    Posts:
    2
    Hello!
    I'm thinking about buying behavior tree. I want to use it in combination with Moremountains TopDown or Corgi-Engine. Both should work quite the same.
    Your discord is closed if you didn't buy the asset yet so I can't ask my question there, I hope it's ok to use this forum:
    Are there any small examples on how you make these two assets work together? I want to let behavior tree move the agents in one scene. Like: "follow the character using A* pathfinding". But the TopDown- or Corgi-Engine must handle the shooting etc. - also the 2D agents would need to face in the right direction (2D sprites) and this is also normally done by the TopDown-Engine.
     
  45. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    Thanks for taking a look at Behavior Designer!

    Unfortunately I haven't really used either asset so I don't have a sample scene, but I can consider this for a future integration.

    With that said, I would approach this by first removing any AI that Corgi or TopDown is adding. From there you could add a behavior tree to your agent and use A* to move your agent. Shooting with Corgi or TopDown can be done without any scripting by using the Behavior Designer reflection tasks, or for more flexibility/performance you can create a small task which interfaces with Corgi or TopDown. You would following this approach for any of the features that you want to use with Corgi or TopDown.

    Hopefully that gives you some direction.
     
  46. sanctanox

    sanctanox

    Joined:
    Sep 22, 2022
    Posts:
    2
    Thank you very much for replying so quickly. This approach should work well! And as Moremountain's assets are quite well known it would be really great to have an integration in the future. This will make the decision to buy behavior designer for other customers much easier. But reading your answer it should work really fine.
     
    opsive likes this.
  47. mick129

    mick129

    Joined:
    Jun 19, 2013
    Posts:
    228
    I'm progressing with the RPGB integration.

    Just one weird challenge and I was wondering if you could point me in the right direction.
    I want the user to tell RPGB who is the target and I want the user to change it through Behavior Designer, but to do so, RPGB needs the CombatEntity.
    Is there a way to find it considering I can't seem to use GetComponent()?

    upload_2023-2-18_21-44-46.png
     
  48. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    Hello,

    For support can you post on the the opsive forums at https://opsive.com/forum? This allows me to track each request better.

    Justin
     
    mick129 likes this.
  49. One_Learning_Man

    One_Learning_Man

    Joined:
    Sep 30, 2021
    Posts:
    81
    I don't frequent Unity or Opsive forum too often but I remember something about Behavior Designer V2 coming out. Is that still happening? If so, what are the big highlights and when? Thanks.
     
  50. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    It's still happening, though likely won't be this year. For version 2 I plan on adding support for DOTS.
     
    DJ_Design and UniqueCode like this.