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:
    4,739
    Thanks for taking a look at Behavior Designer! One of the tasks that Behavior Designer includes is the Utility Selector task, which allows you to use utility theory within behavior trees. The paper that this task is based on is located here.

    There is a Utility Theory Sample Scene that has the agent switching between eating, sleeping, and working, all based on a utility curve. It sounds like this is similar to what you are going for :)

    Behavior trees can be used for either. The utility theory sample is similar to the former, and the Ultimate Character Controller demo tree is more similar to the latter.
     
  2. Nerevar7

    Nerevar7

    Joined:
    Jul 31, 2018
    Posts:
    134
    Thanks for the reply and all the info! Some follow up questions:

    1. I watched the video and was looking through the menus available for the different nodes on the BT. I noticed some of them have prefabs filled in for target objects or things they might be searching for. Currently I'm having my AIs search the scene for Components that might be of use to them (several types of game objects in the scene might have the FoodScource component for example) and then finding the closest one to the agent. Would I still be able to do something similar to this with this asset or do I need to specify a prefab / game object ahead of time?

    2. It sounds like your saying that Utility Theory (didn't know that was the name for it until I read that paper haha) is possible with this asset, that's great! I assume simple scheduling based on some time of day like in Stardew Valley is also possible?

    Thanks again for all the info!
     
  3. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,739
    Your existing workflow works. Tasks in Behavior Designer are very similar to the MonoBehaviour structure so anything that you can do in a MonoBehaviour you can do in a task.

    I haven't played Stardew Valley but you are able to use events within your behavior tree, or create a new conditional task that executes after a set amount of time.
     
  4. Nerevar7

    Nerevar7

    Joined:
    Jul 31, 2018
    Posts:
    134
    Oh great! What I meant with that example is just to have NPCs do predefined things based on the time of day that repeat on a daily or weekly basis, rather than on a Utility Theory type system where they actively seek something that might benefit them.

    Sounds like this might really be useful for me, thanks so much!
     
    opsive likes this.
  5. jrDev

    jrDev

    Joined:
    Nov 5, 2008
    Posts:
    1,687
    Hello,

    Would this be good to use to build AI for a word game (to spell a word from given letters)? If so, are there any examples of this?

    Thanks,
    jrDev
     
  6. opsive

    opsive

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

    While I am sure that you could use behavior trees for something like this, personally I would not start with it. The biggest issue that you need to solve is figuring out what word the AI should return and for that you'd have to develop your own custom task within Behavior Designer. Since you'd be developing your own task you might as well try it first without using behavior trees and then decide if you need to expand on the decision making process by using behavior trees.
     
  7. lThanatosl

    lThanatosl

    Joined:
    Jan 25, 2013
    Posts:
    32
    Hey man,

    Sorry if this has been asked before, but I'm wondering something about Behaviour Designer.

    On huge BTs, checking every single node from the root until the current leaf will be a performance issue. Some games solve this by storing a variable of the latest leaf ran, and running that node directly until sucess/failure/etc. That way you skip every node except the very last one, giving you a big performance boost.

    Is this technique available on your asset? and if not, would it be possible for me to include it? I notice the asset has a lot of .dlls rather than actual code.

    Thanks!
     
  8. KeithBrown

    KeithBrown

    Joined:
    Apr 1, 2017
    Posts:
    119
    Once you purchase the asset you have access to the source code so you can do pretty much anything you want after that.
     
    opsive likes this.
  9. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,739
    Thanks for taking a look at Behavior Designer. Behavior Designer does not rerun the entire tree every frame and it does remember the state from the previous tick. You can use Conditional Aborts if you want to rerun a particular conditional task. This video has some more info about that feature:

     
  10. lThanatosl

    lThanatosl

    Joined:
    Jan 25, 2013
    Posts:
    32
    Oh sick, cheers!
     
  11. tcz8

    tcz8

    Joined:
    Aug 20, 2015
    Posts:
    314
    I think I may have a problem with BD, the moment I added it to my enemy object the editor starts lagging when I select the object in the hierarchy, even with an empty behaviour.

    Trying to scroll down the different components on the enemy object is so slow it's unusable.

    At one point I had to terminate the editor to regain control and just now, with the BD editor opened and the enemy object selected Unity crashed.

    I'm not 100% sure its BD's fault, currently going through all my scripts again to make sure but in the meantime I'm open to suggestions.

    EDIT

    I ran the profiler and it would seem "VisualTreeUpdater.UpdateVisualTree()" is involved, adding over 1000ms each frames and causing a lot of GC alloc.

    I also found out that if I do "unpack prefab" on the enemy object the editor stops lagging.

    Now I'm lost.
     
    Last edited: Jan 7, 2020
  12. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,739
    That's not a method within Behavior Designer so you may want to report the bug to Unity. For further support if you can post on the opsive forum 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.
     
    Duffer123 likes this.
  13. tcz8

    tcz8

    Joined:
    Aug 20, 2015
    Posts:
    314
    Hi thanks for replying, it seems it may NOT be unrelated with BD after all.

    I ran more tests this morning and it seems it has something to do with having several unapplied overrides on the selected prefab.

    When I apply the overrides it stops lagging. I think the only thing BD did was push the list of unapplied setting over the limit where it starts to lag the editor.
     
    opsive and Duffer123 like this.
  14. SickaGamer

    SickaGamer

    Joined:
    Jan 15, 2018
    Posts:
    909
    Does anyone have the files to integrate behavior designer with UFPS 2?
     
  15. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,739
    All of the integration tasks are on this page under Ultimate Character Controller:

    https://opsive.com/downloads/?pid=803
     
  16. SickaGamer

    SickaGamer

    Joined:
    Jan 15, 2018
    Posts:
    909
    :( firewalled off at work
     
  17. CubeGameStudio

    CubeGameStudio

    Joined:
    Dec 1, 2019
    Posts:
    8
    Please, does it have any API documentation? I need to interact with some trees from code and an API documentation would be great. I am trying to find it but still didn't fount it.
     
  18. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,739
    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
     
    CubeGameStudio likes this.
  19. MilziPPG

    MilziPPG

    Joined:
    Oct 9, 2018
    Posts:
    18
    Hey everyone,

    Just started using Behaviour Designer but struggling with certain things. I have an enemy and I want it to attack when it sees the player. I am using More Mountains' Top Down Engine and I'm not sure if this will affect anything.

    So I have set up my AI so that it has a two states - Attacking and Idol. I've also turned off its movement in the Gameobject itself as I don't want to deal with movement until I know some more basic things. I have an entry node, a repeater, and then I have a sequence. The sequence then shoots off another sequence to check if it can see an enemy, and if it cannot, then the enemy is idol. Under the sequence to attack, I first see if the enemy can see the player but then I don't know what to do next. I've read through a bunch of the documentation and can't really find what I'm looking for. But it looks like I need to send a message to the enemy game object telling it call a premade script from the Top Down Engine called Shoot(). That will make the enemy attack constantly.

    I'd be super grateful is someone could tell me what to put in the send message node to be able to call a function and what to put after send message.

    Thank you in advance! Screenshot 2020-01-12 at 21.16.41.png
     
  20. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,739
    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
     
  21. MilziPPG

    MilziPPG

    Joined:
    Oct 9, 2018
    Posts:
    18
    Will do, thank you!
     
  22. pointcache

    pointcache

    Joined:
    Sep 22, 2012
    Posts:
    537
    Hi i've used BD for several years and currently started using it again.
    Im used to the insane lag your node list produces due to lack of basic paging,
    but new lag is actually annoying as hell.
    Basically if i have BD inspector tab open and move any node it starts lagging.
    The lag is bad.
    You have node list tab open - you lag.
    You have inspector open - you lag.
    Only variables tab doesnt lag.
    Can you finally fix this issue, after all these years?
     
  23. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,739
    We've tried to address this in the past but IMGUI doesn't give you much information on this so it ends up causing more problems then it solves. We do have a solution though - we are currently working on a new version which uses Visual Elements instead of IMGUI and for this we already have proper paging when you are viewing the tasks.
     
    pointcache, TeagansDad and xVergilx like this.
  24. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    2,171
    That would be really cool.

    Also, just a 2 cents from me:
    It started lagging more during 2019.2.x cycle. Not sure what's causing this but it might be related to the version change.
     
  25. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,739
    I think that @TonyLi noticed a similar issue with 2019.2. Tony, did you ever figure out the cause? It may just be a general IMGUI performance regression in Unity.
     
    TeagansDad likes this.
  26. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    10,080
    TeagansDad and opsive like this.
  27. pointcache

    pointcache

    Joined:
    Sep 22, 2012
    Posts:
    537
    Thank you.
     
  28. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,739
  29. aerospacevitd

    aerospacevitd

    Joined:
    Nov 29, 2017
    Posts:
    5
    Is there any functionality to display or even edit the behavior tree during a build? I want to be able to show current state of an object during gameplay.
     
  30. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,739
    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. blacksun666

    blacksun666

    Joined:
    Dec 17, 2015
    Posts:
    179
    Any news on the AI deathmatch kit? I bought that asset and all the stuff needed to run it and shortly afterwards you depreciated it rendering all I purchased useless or at the very least unsupported.
     
  32. lsle01

    lsle01

    Joined:
    Oct 9, 2018
    Posts:
    1
    Hi,

    When I update Behavior Designer from 1.6.3 to 1.6.4, my project lose all the enum type shared variables as set before.
    All the enum type shared variables are set to the first enum. I have to fit all the enum type shared variables in my project.
    What can I do to save my project?
     
  33. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,739
  34. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,739
    We will be releasing an update later today which fixes this. If you want this release ahead of time feel free to send me a message with your invoice number and unity version.

    Edit: this update has been released.
     
    Last edited: Feb 14, 2020
  35. blacksun666

    blacksun666

    Joined:
    Dec 17, 2015
    Posts:
    179
  36. gclsw

    gclsw

    Joined:
    Aug 22, 2017
    Posts:
    6
    bug report: When I add many variable to behavior designer view, if I do multiple undo operation. behavior tree will be delete and can not be recover.
     
  37. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,739
    Variable deletion is permanent and doesn't have undo functionality. If you can create a new thread on the opsive forums with the steps to reproduce that'd be great.
     
unityunity