Search Unity

Behavior Designer - Behavior Trees for Everyone

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

  1. radiantboy

    radiantboy

    Joined:
    Nov 21, 2012
    Posts:
    1,633
    yeah I have joined, I just wanted it to work but it seems like it will not.. :( Why I cannot tell,
     
  2. PanthenEye

    PanthenEye

    Joined:
    Oct 14, 2013
    Posts:
    2,063
    Hi! Where can I find the Ludiq's Bolt integration? I recall there being one but I can't find it anywhere on the new website. The integrations part of the documentation doesn't have it.
     
  3. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,126
    All of the integrations are on this page: https://opsive.com/integrations/?pid=803.
     
  4. Shinyclef

    Shinyclef

    Joined:
    Nov 20, 2013
    Posts:
    505
    Asset store sale has me eyeballing Behaviour Designer. I'm making a project using DOTS/ECS and have pondered the question of how to do deal with AI behaviour in a data oriented way that will scale well with ECS.

    Is Behaviour Designer something that can help me with this now or in the future? Have you given much thought to how behaviour trees fit in an ECS world?

    Tried searching this forum for the term ECS but it said search term was too short, so sorry if you've been over this before.
     
  5. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,126
    I have a rough idea, but it's still too soon to really be able to say if it makes more sense to use ECS or stick with the jobs system. Either way I am keeping track of it and will really start working on it when the framework is more mature.
     
  6. tspk91

    tspk91

    Joined:
    Nov 19, 2014
    Posts:
    131
    Hi, can a task variable be shown on the task box in the behavior tree editor? Like a [showintreeeditor]? It would be useful for single object references, so that you can see them at a glance.
     
  7. misanthropowitsch

    misanthropowitsch

    Joined:
    Sep 30, 2016
    Posts:
    23
    Hi!

    I´ve searched fo an concrete answer to my question for some time now, but couldn´t quite make it - so Sorry if it has already been answered. I´ll come straight to the point in order to not bloat my post to much.

    1. Is it possible to design 2D Platformer bosses with mechanics like say Megaman?

    2. Is there already existing logic to instantiate projectiles/execute melee attacks?

    3. How is implementation of logic like instantiating projectiles/execute melee attacks going to work with my own logic?

    4. How is 2D Pathfinding achieved? Do I have to download additional assets like polynav?

    Looking forward to your answers. Lots of questions I know, but I want to make sure i truely understand what I´m about to buy.

    Best,
     
  8. opsive

    opsive

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

    For support can you post on the forum at https://opsive.com/forum? This allows me to track each request better and also has a search to make it easier to find previously asked questions.

    Thank you!
     
  9. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,126
    Yes, especially if you have a scripting background you can create new tasks which allow you to create a wide range of AI.

    Behavior Designer is a behavior tree framework rather than an all in one type of AI asset. The proper way to achieve this is to have Behavior Designer call your character controller and then your character controller performs that attack logic. Take a look at this page for more info: https://opsive.com/support/documentation/behavior-designer/syncing-animations/

    The Movement Pack has a PolyNav integration but you can also use Unity's NavMesh in 2D.
     
  10. dl290485

    dl290485

    Joined:
    Feb 4, 2018
    Posts:
    160
    I'm having some kind of Nav issue.

    I have a Nav Mesh baked and my AI object has a Nav Agent, but the AI has no regard for walls at all, and just tries to push through. If I disable the nav agent, it doesn't seem to make much different, it only create the physical block for the AI to push endlessly against. So with it off, the AI seems to take the same direct path, but they can just wall clip.

    I've used this a while ago and don't remember any other steps. What am I missing for the AI to not avoid obstacles?
     
  11. dl290485

    dl290485

    Joined:
    Feb 4, 2018
    Posts:
    160
    OK so I've messed with it more and found out it's only the 'Move Towards' action I'm having problems with.
    Is this action supposed to use Unity Nav mesh or not? I switched it for 'Follow', and found that follow to my waypoint avoids obstacles.
     
  12. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,126
    Move Towards doesn't use the NavMesh - it just sets the position direction. Seek is the equivalent version that uses a NavMesh.

    For future questions can you post on the forum at https://opsive.com/forum? This allows me to track each request better and also has a search to make it easier to find previously asked questions.

    Thank you!
     
    dl290485 likes this.
  13. Amitloaf

    Amitloaf

    Joined:
    Jan 30, 2012
    Posts:
    97
    I got this:
    10.60923: Watcher - Watcher: Push task Idle (Idle, index 50) at stack index 0
    10.94257: Watcher - Watcher: Conditional abort with task Looked At (BehaviorDesigner.Runtime.Tasks.Sequence, index 7) because of conditional task Can See (CanSee, index 8) with status Failure
    upload_2019-5-16_20-52-35.png
    How can it be the LookedAt conditional abort is breaking the Idle task if the result is Failure? I thought abort lower priority only works if it returns success!
    Can you help?

    (Using version 1.6.1)
     

    Attached Files:

  14. opsive

    opsive

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

    For support can you post on the forum at https://opsive.com/forum? This allows me to track each request better and also has a search to make it easier to find previously asked questions.

    Thank you!
     
  15. p_hergott

    p_hergott

    Joined:
    May 7, 2018
    Posts:
    414
    is there any tutorials that just run a basic set up of ai? I gotta be doing something wrong. If I have a repeater, to a selector. which has 2 children, on the left, can see, seek. and to the right, idle. should the AI not sit idle, until he sees a target, then seeks it? then if he cant see, return to idle?
     
  16. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,126
    This video should help you get going in the right direction:



    If you have any more questions about your tree setup feel free to post on the opsive forums.
     
  17. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    3,296
    Hi, got a BT question. I've got the following branch:
    upload_2019-6-8_19-25-37.png
    What I'm trying to achieve is this: When enemy doesn't have a target, detect it first, then wander if it is not detected.
    But there's an issue. Once Wander is starts running (and returns TaskStatus.Running), the conditionals aren't being checked anymore.

    Which leads to forever stuck in wander behaviour.

    Is there a way to ensure that is "Target is missing" and "Detect" sequence is being ran, while Wander is running?

    I'm not that savy when it comes to BT design, please point me to the right direction.
    There's probably an easy solution, but I can't figure it out for some time now.
     
  18. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    3,296
    Ok, seems like it was really easy.

    I should've done this instead:
    upload_2019-6-9_13-25-57.png

    Setting Detect to conditional abort - both did the trick, as well as moving wander to lower priority;

    Re-watching this helped a lot:
     
  19. SLThompson

    SLThompson

    Joined:
    Feb 7, 2014
    Posts:
    49
    Are you integrating this with Photon (PUN2), I saw you've done the character controllers.
     
  20. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,126
    I've thought about it but with multiplayer you generally don't need an integration at the behavior tree level. Your AI agents should be running on the host (the Master Client in the case of PUN), and the actions performed by the behavior tree should then be synchronized. In the case of the character controllers these actions are what are synchronized, and not the actual behavior tree flow.
     
  21. lolingloled

    lolingloled

    Joined:
    Sep 6, 2017
    Posts:
    2
    Hello. I am building a behavior tree with behavior designer which has two branches in parallel.

    I want the left branch to be reevaluated every tick and the right branch to stay on several actions which have a task status of running.
    The problem is that when the right brach stays at running on a tick, the next tick the behavior tree would start executing from that action without reevaluating the left branch.

    Is there a way I can achieve this?

    Thank you in advance.
     
  22. opsive

    opsive

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

    For support can you post on the forum at https://opsive.com/forum? This allows me to track each request better and also has a search to make it easier to find previously asked questions.

    Thank you!
     
  23. lolingloled

    lolingloled

    Joined:
    Sep 6, 2017
    Posts:
    2
    I will, thank you!
     
  24. pierre92nicot

    pierre92nicot

    Joined:
    Aug 21, 2018
    Posts:
    57
    Hi, is there a way to make the "can see object" field of view parent of a gameobject ?
    So the field of view can follow the head of my character.
    Thanks !
     
  25. opsive

    opsive

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

    For support can you post on the forum at https://opsive.com/forum? This allows me to track each request better and also has a search to make it easier to find previously asked questions.

    Thank you!
     
  26. Danistmein

    Danistmein

    Joined:
    Nov 15, 2018
    Posts:
    82
    Hi, Opsive, this tool is very cool. And I have seen your tutorials. I am finding an AI solution, and it seems like it is the best choice for me. I am beginner, I have one question. I have probably 200 different AI units in a scene, is it efficient to handle these 200 units simultaneously?
     
  27. christougher

    christougher

    Joined:
    Mar 6, 2015
    Posts:
    558
    Yes Behavior Designer itself can handle 200 units great. It actually has very little overhead, but the question tends more to be whether Unity can handle the 200 units. If you have BD handling the animating and navigating and raycasting then those underlying Unity actions will slow things down.
     
    Danistmein and opsive like this.
  28. Danistmein

    Danistmein

    Joined:
    Nov 15, 2018
    Posts:
    82
    Thanks for the reply.
     
  29. pit-travis

    pit-travis

    Joined:
    Sep 17, 2018
    Posts:
    14
    What's the recommended way of setting public variables in tasks inside an external behaviour tree, per instance, i.e such that.I can set different variables for different gameobjects that end up using a behaviour that contains that tree.

    For example, I'm creating a simple patrol script where entities patrol between different waypoints. I want to be able to set a different group of waypoints for different gameobjects that use that patrol behaviour. I'd do that using a public variable in the Action that contains the different waypoints (in the form of transforms). But as far as I can see, I can't assign a value to that variable from anywhere outside the behaviour editor as-is.

    Currently I would do it this way:

    1. Change the public variable into a SharedVariable
    2. create a 'blackboard' variable and assign it to the SharedVariable from step (1)!
    3. write a custom monobehaviour for the gameobjects using that subtree somehow and set the variable of the BehaviourTree component in there.

    This is all quite cumbersome, is there a faster way to do it?
     
  30. opsive

    opsive

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

    For support can you post on the forum at https://opsive.com/forum? This allows me to track each request better and also has a search to make it easier to find previously asked questions.

    Thank you!
     
  31. Fragment1

    Fragment1

    Joined:
    Aug 30, 2013
    Posts:
    67
    Is there a load balancing strategy for running behaviours built in anywhere?

    I want to run my AI's "tick" at 0.2 second intervals, however with 1000 entities, this is just causing a spike to happen 5 times a second.

    Is there a built in method to spread the processing out across multiple frames?
    For example cap the processing to 200 units per frame then spill the overflow into the next, but maintain a 200ms gap between ticks?

    The order itself isn't important, nor is the specific frame at which an AI fires. All that matters here is merely that they fire once every 0.2 seconds.
     
  32. opsive

    opsive

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

    For support can you post on the forum at https://opsive.com/forum? This allows me to track each request better and also has a search to make it easier to find previously asked questions.

    Thank you!
     
  33. RegdayNull

    RegdayNull

    Joined:
    Sep 28, 2015
    Posts:
    68
    Is there any not ugly way, to transfer time delta into task? While saying ugly I mean global variables and shared variables at all. I can call BehaviourManager tick with timer or even manually, but can't find way to send and read that delta.
     
  34. opsive

    opsive

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

    For support can you post on the forum at https://opsive.com/forum? If you can also give more details on your question that would be great. This allows me to track each request better and also has a search to make it easier to find previously asked questions.

    Thank you!
     
  35. Danistmein

    Danistmein

    Joined:
    Nov 15, 2018
    Posts:
    82
    Hello, Opsive.

    Today, I developed my Game AI as usual. After I assigned a global variable to a local variable in the specific task, all behaviors disappeared, and print these error messages on the console. What should I need to do to fix this problem? This behavior has taken me some days to optimize. I don't know what I need to do now, and I am afraid of losing all of these tasks. These are the error message.

    Best regards.

    error1.png error2.png error3.png
     
  36. Danistmein

    Danistmein

    Joined:
    Nov 15, 2018
    Posts:
    82
    I have gotten help from discord. using JSON instead of binary serialization in the Behavior Designer preferences can fix this problem. But the tree has corrupted can't restore by itself. ;);)So, the most important thing is back up your project regularly.
     
  37. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,126
    In the next version of Behavior Designer you will be able to load the tree in a worker thread. If you'd like to test this out ahead of time feel free to send an email to support@opsive.com with your Behavior Designer invoice number and Unity version.

    Thanks!

     
  38. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,126
    Behavior Designer 1.6.3 has been released on the Asset Store. The major feature for this version is the ability to load your behavior trees in a separate thread. Note that because you can only access Unity objects on the main thread if you have any property mappings then you will not be able to use this feature for your behavior tree.
     
  39. rajdpj

    rajdpj

    Joined:
    Jan 19, 2019
    Posts:
    4
    I am currently using the behavior designer Cover task with unity and have the following questions:
    1. How does the Cover task decide which side of an object (i.e. a wall) to hide behind? is it using the forward vector of the cover gameobject?
    2. Does the cover object have to be a mesh? if so, should the cover be a simple mesh so that the normal is a large area?
    3. The cover task does not move to next task if Max Look At Rotation Delta is zero, what is the purpose of the Max Look At Rotation Delta setting?
    4. Is there any way, other than looking at the code of each task, to find a detailed explanation of the behavior designer parameters and their effects related to each tasks(i.e Cover(Max Look At Rotation Delta), etc). any response is greatly appreciated.
     
  40. opsive

    opsive

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

    For support can you post on the forum at https://opsive.com/forum? If you can also give more details on your question that would be great. This allows me to track each request better and also has a search to make it easier to find previously asked questions.

    Thank you!
     
  41. rajdpj

    rajdpj

    Joined:
    Jan 19, 2019
    Posts:
    4
    Justin,
    I appreciate your reply, I have posted my question in the Opsive forum. Thank you in advance for your cooperation.
     
  42. Gildar76

    Gildar76

    Joined:
    Oct 6, 2015
    Posts:
    20
    Hi,

    I'm thinking about buying Behaviour designer but I have a few questions. I've seen similar questions, but still not sure.

    Does anything prevent me from using Joobs and burst compiler in my own custom tasks in the current version?

    I read somewhere that Behaviour designer supports up to version 2018.3. Does it hwork in 2019.X?

    I guess it's to early to say if it'll work in 2019.3 but do you see any problems with the UI changes?

    Thanks
     
  43. opsive

    opsive

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

    I haven't tried using a job within a custom task but there isn't anything that would stop you. Keep in mind that Behavior Designer itself doesn't use the job system.

    Behavior Designer works with up to Unity 2019.2. The UI doesn't look good right now in 2019.3 but when that is released I'll submit an update.
     
  44. DigitalAdam

    DigitalAdam

    Joined:
    Jul 18, 2007
    Posts:
    1,204
    @opsive

    Hi, I'd like to use Behavior Designer for a game I'm creating for the Oculus Quest. Would this be a good solution for AI since I'm limited on performance?

    Thanks.
     
  45. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,126
    Thanks for taking a look at Behavior Designer. Traversing the tree is extremely quick so it should work fine on the Quest. Whenever there is a performance problem related to Behavior Designer it is generally related to one of the tasks that you are running instead of the actual behavior tree implementation.
     
    DigitalAdam likes this.
  46. kbengine

    kbengine

    Joined:
    Jun 20, 2019
    Posts:
    4
    Why is there no SharedLayerMask?
    CanSeeObject and so on can use SharedLayerMask just fine.
    I can change the LayerMask dynamically.

    using UnityEngine;

    namespace BehaviorDesigner.Runtime
    {
    [System.Serializable]
    public class SharedLayerMask : SharedVariable<LayerMask>
    {
    public static implicit operator SharedLayerMask(LayerMask value) { return new SharedLayerMask { mValue = value }; }
    }
    }
     
  47. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,126
    I'll add this to the next version :)
     
  48. kbengine

    kbengine

    Joined:
    Jun 20, 2019
    Posts:
    4
    Hi,
    I want the agent to stop 10 meters from the destination (Seek.cs: arriveDistance=10).
    But the agent went to the destination (distance 0 meters).

    The code does not set NavMeshAgent.StoppingDistance, and navMeshAgent.remainingDistance always uses float.PositiveInfinity. When the navigation system stops, it must have reached the destination (distance 0 meters).

    What did I do wrong? Unity2019.2.10f1
    The problem is like: https://forum.unity.com/threads/remaining-distance-returns-infinity.622396/

    NavMeshMovement:
    Code (CSharp):
    1.    
    2.  [Tooltip("The agent has arrived when the destination is less than the specified amount. This distance should be greater than or equal to the NavMeshAgent StoppingDistance.")]
    3.         public SharedFloat arriveDistance = 0.2f;
    4.  
    5.         public override void OnStart()
    6.         {
    7.             navMeshAgent.speed = speed.Value;
    8.             navMeshAgent.angularSpeed = angularSpeed.Value;
    9.             navMeshAgent.isStopped = false;
    10.             startUpdateRotation = navMeshAgent.updateRotation;
    11.             UpdateRotation(updateRotation.Value);
    12.         }
    13.  
    14.         protected override bool HasArrived()
    15.         {
    16.             // The path hasn't been computed yet if the path is pending.
    17.             float remainingDistance;
    18.             if (navMeshAgent.pathPending) {
    19.                 remainingDistance = float.PositiveInfinity;
    20.             } else {
    21.                 remainingDistance = navMeshAgent.remainingDistance;
    22.             }
    23.  
    24.             return remainingDistance <= arriveDistance.Value;
    25.         }
     
    Last edited: Oct 31, 2019
  49. opsive

    opsive

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

    For support can you post on the forum at https://opsive.com/forum? If you can also give more details on your question that would be great. This allows me to track each request better and also has a search to make it easier to find previously asked questions.

    Thank you!
     
  50. PaperMouseGames

    PaperMouseGames

    Joined:
    Jul 31, 2018
    Posts:
    434
    Hi there! I'm looking into expanding my NPC AI system to be a little more organic with more complex NPC behaviors such as schedules (like Skyrim and Stardew Valley).

    If possible I would also like to have a system where NPCs in the town dynamically attempt to achieve goals, like eating if they get hungry, socializing if they are lonely, etc.

    Is this something Behavior Designer could really help with? Sorry if this is a dumb question, but I really just learned about Behavior trees and was trying to code all this stuff up from scratch up until now.

    If anyone has some examples / tutorials of how this could help with those tasks I mentioned I would really appreciate it, thanks!

    EDIT: I should try to be more clear I think, I guess I'm asking if this asset helps to set up NPC waypoints and logic used for dynamically choosing goals based on factors or if this is more about organizing the logic you've already written for your NPC. I should also specify that I am using Unity's NavMesh agent system currently.
     
    Last edited: Nov 6, 2019