Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Behavior Designer - Behavior Trees for Everyone

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

  1. EternalAmbiguity

    EternalAmbiguity

    Joined:
    Dec 27, 2014
    Posts:
    2,142
    I don't see anything that lets me get the "Value" property.

    devenv_2018-01-25_10-09-21 Mod.png

    It's not visible in that image, but I do have both of these at the top:

    using BehaviorDesigner;
    using BehaviorDesigner.RunTime.Tasks;

    Edit: Never mind - I just realized you said to change the importance variable, not the behavior tree variable ThirstImportance. Sorry, it does work. Thanks.

    @opsive

    Edit: How do I know what order a sequencer plays its subsequent tasks in?

    Also, is there any way to make these somewhat modular? As you can see, I'm doing basically the same thing four times...if I were passing in a variable to a method I could use the same method four times, but I'm not sure how to do that with Behavior Designer.

    Additionally, I created an empty GO and added a behavior manager script to it. However, it does not become enabled when I play the scene. What should I do to fix this?

    Overall I'm trying to compare the importance values. I was planning to have a conditional after those 4 do that, but I'm not really sure how to do that. Can you give any advice? I tried to take a look at the example scenes on your website but when loading any of them there are errors and scripts don't seem to be attached properly to the GOs. I'm running Unity 2017.2.
     
    Last edited: Jan 25, 2018
  2. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,679
    A sequence task plays the tasks from left to right. Take a look at this video:

    http://opsive.com/assets/BehaviorDesigner/videos.php?id=18

    You can use an external tree to reuse subtrees. Take a look at the RTS sample project for an example. This video also goes through it:

    http://opsive.com/assets/BehaviorDesigner/videos.php?id=8

    The BehaviorManager just executes the behavior trees - it doesn't actually contain the behavior tree. Unless you are changing the update type in general you don't need to manually add it.

    A lot of the sample scenes are integrations which require the other base asset, but the top 5 samples do not require any other assets.

    I highly recommend taking a look at this page and following the behavior tree that it talks about. In it each task is described so you should be able to get an idea on how to structure a complex behavior tree.
    http://opsive.com/assets/DeathmatchAIKit/documentation.php?id=3

    For more getting started tutorials take a look at the playlist below
     
  3. EternalAmbiguity

    EternalAmbiguity

    Joined:
    Dec 27, 2014
    Posts:
    2,142
    It's a shame there isn't more written documentation, because that's superior to video. However I'll take a look at these and see if they show me what I need to know.

    For this specifically:

    I am indeed planning to change the update type. I intend to have dozens of agents all using the behavior tree so I'll need to slow the update interval (and I may make it agent-dependent).
     
    blitzvb likes this.
  4. Shakkar

    Shakkar

    Joined:
    Sep 18, 2017
    Posts:
    5
    So I just started with Behavior Designer, and I figured a good place to start would be to see if I could remake a MonoBehaviour script I have that's already working.
    At the start of the script I fill an array with objects that have the "Enemy" tag and then iterate through the array.

    Code (CSharp):
    1. possibleTargets = GameObject.FindGameObjectsWithTag("Enemy");
    2. foreach (GameObject go in possibleTargets)
    3.         {
    4.                 //dostuff
    5.         }
    I've setup a "Find Game Objects With Tag" task in Behavior Designer and created a variable of type GameObjectList, the list is populating exactly like it does in my script.

    However I am a little lost as to how to find/reference a single element from the GameObjectList. Even putting aside iterating through the GameObjectList. I know I could make my own task to handle this, I just wanted to see if there was something I was overlooking.
     
  5. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,679
    Are you referring to within the behavior tree that you want a task to operate on a single element, or you're wanting to access a single element out of a SharedGameObjectList? There isn't an included task which takes the element out of the list and returns it as a SharedGameObject but it would be pretty easy to create:

    Code (csharp):
    1.  
    2. public SharedGameObjectList myList;
    3. public SharedInt index;
    4. public SharedGameObject storedValue;
    5.  
    6. public override TaskStatus OnUpdate()
    7. {
    8.    storedValue.Value = myList.Value[index.Value];
    9.    return TaskStatus.Success;
    10. }
    11.  
    You'd want to add some error checking but this will get the value at the specified index. From here you can then use that stored object within any task that accepts just a GameObject.
     
  6. Shakkar

    Shakkar

    Joined:
    Sep 18, 2017
    Posts:
    5
    Thank you very much for that. Yeah, I had been looking to reference a single element from within the behavior tree. Your were right, that wasn't hard at all. I took your advice and got all the error checking I could think of in. Here's the full task I ended up with.

    Code (CSharp):
    1. namespace BehaviorDesigner.Runtime.Tasks.Basic.SharedVariables
    2. {
    3.     [TaskCategory("Basic/SharedVariable")]
    4.     [TaskDescription("Sets a specified SharedGameObject from a SharedGameObjectList. Returns Success.")]
    5.     public class SetSharedGameObjectFromSharedGameObjectList : Action
    6.     {
    7.         [Tooltip("The SharedGameObjectList to get the SharedGameObject from.")]
    8.         public SharedGameObjectList myList;
    9.         [RequiredField]
    10.         [Tooltip("The Index from the SharedGameObjectList")]
    11.         public SharedInt index;
    12.         [Tooltip("The SharedGameObject to set")]
    13.         public SharedGameObject storedValue;
    14.         [Tooltip("Can the target value be null?")]
    15.         public SharedBool valueCanBeNull;
    16.  
    17.         public override TaskStatus OnUpdate()
    18.         {
    19.             storedValue.Value = ((myList.Value[index.Value] != null || valueCanBeNull.Value) ? myList.Value[index.Value] : gameObject);
    20. //            storedValue.Value = myList.Value[index.Value];             //nocheck
    21.             return TaskStatus.Success;
    22.         }
    23.  
    24.         public override void OnReset()
    25.         {
    26.             valueCanBeNull = false;
    27.             myList = null;
    28.             index = null;
    29.             storedValue = null;
    30.         }
    31.     }
    32. }
    33.  
    I think that covers everything? Thanks again for the help, I was exploring through all the various tasks for an unfortunate and embarrassingly long time trying to see if any one of them already did what I was looking for.
     
  7. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,679
    Glad you got it!

    I would change the if statement to:

    Code (csharp):
    1.  
    2. var listValue = (index.Value >= 0 && index.Value < myList.Value.Count) ? myList.Value[index.Value] : null;
    3. if (listValue == null && !valueCanBeNull.Value) {
    4.    listValue = gameObject;
    5. }
    6. storedValue.Value = listValue;
    7.  
    This way you are checking the bounds of the list to ensure you don't get an out of index exception.
     
  8. Cartoon-Mania

    Cartoon-Mania

    Joined:
    Mar 23, 2015
    Posts:
    304
    I know you are offering utility ai. But I know there is no Visual Curve Editor. I finally found what I wanted. It is DecisionFlex.

    https://www.assetstore.unity3d.com/en/#!/content/8967

    Can the Behavior Designer and DecisionFlex work together? If so, can you simply tell me how?
     
  9. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,679
    I haven't used DecisionFlex so I'm not sure - I do the integrations based on the number of requests that I get for a particular asset so if anybody else would like to see a DecisionFlex integration please let me know.
     
  10. blitzvb

    blitzvb

    Joined:
    Mar 20, 2015
    Posts:
    284
    Not necessarily this but a curve editor for the utilitly node is seriously a must have.
     
  11. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,679
    Behavior Designer will draw AnimationCurves so in the task inspector you can see the curve for the utility tasks:

    curve.PNG

    Clicking on this curve will then bring up Unity's editor:

    curve details.png

    Or are you referring to something else?
     
    blitzvb likes this.
  12. blitzvb

    blitzvb

    Joined:
    Mar 20, 2015
    Posts:
    284
    It’s just great! I do not have your asset yet because I am not yet at the AI phase ;)

    Thanks.
     
    opsive likes this.
  13. Duffking

    Duffking

    Joined:
    Oct 3, 2014
    Posts:
    24
    Hi Opsive, got a bit of a problem I can't get my head around and was hoping for a little advice. I've just got home so I've attached a diagram from memory of the branch in question, which is the lowest priority branch of a selector above it. I hope I don't do a terrible job of explaining this.

    I've got an NPC with two active behaviour trees; the first is a simple detection behaviour. If I enter a certain radius of the NPC, a value (call it Bool Y) gets updated to true saying that the NPC is paying attention to my presence. After 10 seconds or so, it resets the value back to false.

    The other tree essentially controls an animator through listening to that value, and some other ones elsewhere. One of the tree's branches (which I did the diagram of) is entered by the NPC being in an idle state (call it Bool X). Due to stuff in the rest of the tree, bool Y will always be false on entering this branch.

    What I need to achieve is that when entering the branch successfully, the NPC is set to play an idle animation until Bool Y changes value. When it changes value (I am using a custom task for detecting a change in the value), I want to see what the value changed to, then play an appropriate transition for that change (again using a custom task but this one basically just combines a bool test and a play anim task into one for tidiness), then play the corresponding idle once the transition finishes We then idle task until that value changes again. At any point this branch might be broken out of by the NPC not being idle any more, at which point the other tree sets Bool Y to false again in preparation for the event that we re-enter this branch later.

    What I have in the diagram works, however if we leave the branch for a higher priority one while Bool Y is true and return again later, since it was set to false elsewhere, when I re-enter this branch, the task immediately knows that it changed and rather than skipping the left most branch and just playing the correct idle from the middle branch, it plays a transition and then idles, which looks weird.

    I've tried a few different approaches to fix it but hit a dead end. The crux seems to be the need to not play a transition on entering the branch, just the idle, and then play a transition whenever Y changes, along with a matching idle. As far as I can tell I can't do this with a simple "is bool true/false" since the character would play the transition, then get to the idle and immediately play the transition again since the bool is still true, rather than changing.

    Basically, I think I need that "on value change" re-evaluation to ignore if that value changed while I was in a higher priority branch? Is that possible? If not I was wondering if you guys have a recommendation for writing a task which is used for re-evaluating/aborting another if the value changes at all rather than simply if a specific value is found?
     

    Attached Files:

  14. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,679
    Generally for animation I recommend that be controlled within your character controller rather than the behavior tree. For simple animators it doesn't matter so much but as your animator gets more and more complicated it's easier to abstract that logic into the character controller. This also makes your behavior tree not depend on the animation state which helps clean up the logic. Take a look at this page for more info: http://opsive.com/assets/BehaviorDesigner/documentation.php?id=135
    Conditional aborts make it easy to reevaluate but they don't work in all cases. For complete control over when the tasks abort I recommend using the Interrupt/Perform Interruption tasks. With these two tasks you can control exactly when the tasks are aborted so you'll have complete control. Take a look at the CTFsample project for an example of using the interrupt tasks. I also go over it in this video: http://opsive.com/assets/BehaviorDesigner/videos.php?id=7
     
  15. Duffking

    Duffking

    Joined:
    Oct 3, 2014
    Posts:
    24
    Thanks, I had a play with the interrupts but didn't get too far, so I took your advice and had a rethink of how I was working this stuff and reworked the entire system into one with a couple of independent trees keeping track of / setting variables on and off while another system reacts to those variables in order for animations to work. Works great and seems a lot closer to what your intended usage is!
     
    opsive likes this.
  16. oded

    oded

    Joined:
    Jun 7, 2013
    Posts:
    7
    how to export the tree of the behavior designer to visual studio
     
  17. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,679
    Are you referring to generating c# code? Behavior Designer doesn't generate any c# code for your tree - it is has a runtime component which executes the serialized tree.
     
  18. oded

    oded

    Joined:
    Jun 7, 2013
    Posts:
    7
    Is it possible to use behavior tree of the behavior designer outside unity In some way

    Thanks
     
  19. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,679
    It's not built in but if you download the runtime source you can then strip out any UnityEngine dependencies. I've heard of a few people doing this and they didn't ask me many questions about it which generally means they didn't have a problem.
     
  20. oded

    oded

    Joined:
    Jun 7, 2013
    Posts:
    7
    Thank you so much
     
  21. chaneya

    chaneya

    Joined:
    Jan 12, 2010
    Posts:
    402
    Justin,

    1. I have some very odd behavior going on with my enemy characters using Behavior Trees. I'm using the latest release Unity 2017.3.1. My enemy character is setup so the entire tree is exposed in the scene meaning I'm not using any external tree references. My enemy character in scene works as expected. On the Behavior Tree component, I have Start When Enabled checked. All other options are unchecked.

    Here's the weird part: The original enemy character works as expected. If I duplicate the character or drag a prefab clone of the enemy character into the scene, the tree stops after the first update loop. It comes to a complete halt. In my tree, the task it stops at is a Wait task. So the tree just sits there stuck on that wait task. It doesn't really have anything to do with the wait task. It has to do with the fact that the tree is running one update and then just stops. I can place a break point in the OnUpdate method in the Wait task where it looks to see if StartTime + Waitduration is less than timetime. It will hit that break point once and then not again and the tree stays stuck on the wait task highlighted in green. In the original version, it hits that break point numerous times until it achieves success, then the tree continues as expected. I can fix this issue on the duplicate by checking Restart When Complete and then when I press play the tree runs as expected. The question is why do I need to have Restart When Complete checked on the duplicate when it is not checked on the original?

    I'v never experienced a situation where an exact duplicate of a gameobject acts differently from it's original. And it appears to be the Behavior Tree that is acting differently.

    2. I can't guarantee these two issues are related but just prior to noticing this weird behavior with duplicate trees acting differently, I again received the error "KeyNotFoundException: The given key was not present in the dictionary." I've had this error several times in the past but was never able to retrace my steps that created it. This time however before I pressed play and was able to see the spammed error message in the console, I clicked Apply to save changes made to the enemy character to a prefab. And then I backed up my project. The next time I opened my project, I had the KeyNotFound error. So now I have a project that is basically corrupted. Error #1 above is in my project where I basically rebuilt the enemy character behavior tree from scratch, copying and pasting all of the pieces and parts into a new Behavior Tree. So I fixed the KeyNotFoundException error but was left with a weird duplicate issue.

    I would be happy to provide you a copy of the project with the spamming KeyNotFoundError message and if you have any thoughts as to what is going on with the duplicate issue, that would be great.

    PS: After writing this long winded post, it occurred to me that I might just try deleting the gameobject with the Behavior Manager component from the scene and recreating it. That appears to fix both issues. In both my "corrupted" project with the Ketnotfoundexception and my issue with duplicate trees acting differently, simply deleting and recreating the Behavior Manager fixed both problems.

    Thanks
    Allan
     
  22. blitzvb

    blitzvb

    Joined:
    Mar 20, 2015
    Posts:
    284
    Hey,

    Do you plan to support the new c# job system in order to multi tread on multi core computer the AI?

    Thanks in advance.
     
  23. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,679
    I'm glad that you got it working, though it's odd that deleting the BehaviorManager fixed it. The BehaviorManager doesn't persist any information so that shouldn't have affected things. If you want to send me a repro project of it not working I can take a closer look at the issue.
     
  24. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,679
    Yes, I do, though I don't have a timeframe for it. The jobs system is a completely new programming design so it'll take some time for both that platform to mature and to determine how it can best be used with Behavior Designer. I am following along with how it is progressing though.
     
    Sylmerria and blitzvb like this.
  25. chaneya

    chaneya

    Joined:
    Jan 12, 2010
    Posts:
    402
    Justin,

    Thanks I'll get the project to you. I spoke too soon, it turns out I have to remove and add the Behavior Manager component every time I open my scene in order to get the enemy tree working.

    Allan
     
  26. chaneya

    chaneya

    Joined:
    Jan 12, 2010
    Posts:
    402
    Justin,

    Update on the errors I've been having. It turns out if I remove the Behavior Manager gameobject/component from my scene and let Behavior Designer instantiate that component into the scene at runtime, all of the bugs go away. I think this is a script execution order problem....something to do with OnEnable and Properties.

    As soon as I get home today or tomorrow, I'll still shoot you the project with the documentation of the bugs. But it looks like this fixes the problem.
     
  27. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,679
    Yeah I'd love to take a look. You can send it to support@opsive.com
     
  28. username132323232

    username132323232

    Joined:
    Dec 9, 2014
    Posts:
    439
    I have an NPC with a BT attached and walking around the scene. I would like him to jump when he walks into a certain zone designated by a collider. The NPC already has a function Jump(), so I guess what I need is a task in the BT that would detect entering/exiting the collider and run simultaneously with whatever behavior is already in the BT.

    Do you have any samples that show how exactly to do that?
     
  29. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,679
    The MiniGauntlet sample project has the character jumping when in a trigger, but that scene is setup to show a specific feature of the behavior tree so I wouldn't go by that. The correct way to handle this is to not have jump within the behavior tree at all and instead use something like the off mesh links with your NavMeshAgent (or equivalent pathfinding solution). I found this post which has an implementation similar to what I am referring to.
     
    username132323232 likes this.
  30. username132323232

    username132323232

    Joined:
    Dec 9, 2014
    Posts:
    439
    Thanks Justin! That's exactly what I was looking for!
     
    opsive likes this.
  31. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,679
    The Movement Pack's A* integration has been updated to support the new IAStarAI interface in the A* Pathfinding Project. This eliminates the need for having separate tasks for RichAI and AIPath and should make things a lot more streamlined. You can get it on the integrations page.

    From what I've played with I also think this new interface will make it a lot easier to support A* for the Tactical and Formations Pack :)
     
    Sylmerria and username132323232 like this.
  32. Shinzironine

    Shinzironine

    Joined:
    Nov 30, 2013
    Posts:
    32
    We've been using Behavior Designer without any problems for quite some time, but suddenly stumbled upon one problem - it does not work for some reason on iOS in our project. I assume that the problem could be with our implementation, but I want to ask before searching further - are there any special options (flags maybe) that should be set for mobile. Thanks.
     
  33. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,679
    No special flags need to be set. What error are you getting? Have you tried a fresh project?
     
  34. Th0re

    Th0re

    Joined:
    Sep 4, 2015
    Posts:
    32
    Hi Opsive,
    I somehow switched on the current task labels in the Game View. I have clicked through all sorts of Gizmos and preferences and I just can't find where to to switch it off. Could you tell me where I find the setting?
     
  35. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,679
    It sounds like you've added the BehaviorGameGUI component to your tree - when you remove this it'll also remove the labels.
     
    Th0re likes this.
  36. Ramulos

    Ramulos

    Joined:
    Feb 19, 2017
    Posts:
    49
    Hello,

    I bought behavior designer with the movement pack and was trying to work with some simple trees and noticed that the wander action was causing severe lag. In the profiler it shows it using up 96% of the resources whenever it looks for another position to go to.

    image.png
    This is causing the entire game to freeze when it looks for another position. The tree is literally just the entry connected straight to a wander action. Is it supposed to be this resource intensive? Is it cause of unity's navmesh? Any alternatives? Thank you for any and all your help.
     
  37. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,679
    When wander picks a new position to move towards it does a NavMeshAgent.SamplePosition to ensure that position is valid. That's an extremely long time for a single SamplePosition call - you should report it to Unity so they can take a look at why it is taking so long. There isn't an option within wander to disable the sampling of the position but you could just have NavMeshMovement.SamplePosition return true and then it won't do the sample.
     
  38. somosky

    somosky

    Joined:
    Feb 15, 2014
    Posts:
    117
    Hi I'm currently working on the AI for my game and for the most part am pretty happy with the results. The one issue I am having though is with AI jumping. I'm using Navmesh agents for enemy movement and am able to get the enemies to jump gaps in the NavMesh using the Off link mesh but haven't been able to figure out how I can make the AI jump up to another NavMesh. So for example I have a tiny city and the street is a Navmesh and all of the buildings roofs are Navmeshes. My player can jump to the roofs but my AI just stay on the street NavMesh and can't pursue vertically by jumping. It seems like the Off Link Mesh jump only works if the baked meshes have the same Y transform. So is this something that behavior designer could help with and if so what would be the workflow of that?
     
  39. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,679
    Unfortunately it doesn't sound like it. Behavior Designer can use Unity's NavMesh implementation but it doesn't do the actual pathfinding/traversal so in that regard it doesn't help. I haven't encountered a similar situation to yours though but you may want to try the free version of A* Pathfinding Project to see if it handles your use case better. If that works and you decide to use behavior trees the Movement Pack is integrated with A*.
     
  40. Duffer123

    Duffer123

    Joined:
    May 24, 2015
    Posts:
    1,033
    @opsive ,

    Have owned this Asset and add ons for some time and have now come back to them again when I realised the generic AI assets just aren't tailorable enough for me.

    I've got a few basic questions:

    - is there any way to have nested behavior trees... to save yourself from potentially massive trees?

    - I think you can, but can you have more than on behavior tree operating on a GameObject at once?

    - Can you turn GameObjects carrying one or more behavior tree components in to a prefab?

    - Can you have behavior trees on child GameObjects and on their parent?

    - could I create a behavior tree task which took in a say string and outputted a float... A variable conversion task?

    All these questions and more! ;)
     
  41. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,679
    A whole bunch of yeses :)
    Yes, you can use external trees.

    Yes
    Yes
    Yes
    Yes
     
  42. Duffer123

    Duffer123

    Joined:
    May 24, 2015
    Posts:
    1,033
    @opsive ,

    Hah! Brilliant. Thanks. All those yesses are v reassuring...
     
  43. Duffer123

    Duffer123

    Joined:
    May 24, 2015
    Posts:
    1,033
    @opsive ,

    Just playing around and I've got a basic behavior, a sequential with some tasks under it. The first action task builds firstString and secondString in to thirdString and the second action task under the sequence Logs thirdString - but when I run it nothing appears in console? I would expect to see the value of thirdString in the console as when you debug log something out to console? Using the Log action and LogValue actions (both outputting thirdString) and still no joy - it all plays through and ticks. [edit] if I tick the errorLog it then outputs as an error to the console?
     
    Last edited: Mar 9, 2018
  44. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,679
    Based on that it sounds like you've disabled the standard output within the log console. Especially if log error works then the task is definitely running and would be doing a Debug.Log.
     
  45. PerunCreative

    PerunCreative

    Joined:
    Nov 2, 2015
    Posts:
    83
    Hi,

    I have performance issues in the editor. When I am in the play mode and I have only game window active then everything runs just fine, but when the scene view is active as well then there is a huge performance impact (50 - 60fps -> ~10fps). First I though that it is caused by drawcalls overhead or something like that, but then I have discovered that if there are no active Behaviors then Game + Scene view remains at ~60fps.

    After some time I have discovered that if there is at least one Behavior in the behaviorTrees list then the performance goes down (but only when the scene view is opened). I tried changing Gizmos View Mode to Never, removing Gizmos methods from Behavior, closed Behavior Designer window, etc. but the result was the same.

    I am using unity 5.6 + BD version 1.5.11 with full source code from the website, however the editor/GUI source code is only in the dll. I was trying to find out what might be the cause of the bottleneck in the editor using .Net decompiler, but without proper debugging it is way too time consuming to tell what is the issue just from looking to the dll. Could you please look in to that issue? If there is some kind of necessary logic for the BD window, then it would be nice to have at least option to turn it off if you are not currently using the BD window, so that you can work on other things more smoothly without turning off the whole AI. But If there is no time for that at the moment, could you please release BehaviorDesignerEditor source code on your website so that I could change it my self? Thanks

    example1.JPG

    tree_client2.JPG
     
  46. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,679
    Can you profile the editor and tell me which method is causing the bottle neck? I just tried it and didn't have any performance issues when I tried my test scene so it could be related to your specific setup. If you want to send me a repro scene to try out you can also do that - support@opsive.com.
     
  47. chaneya

    chaneya

    Joined:
    Jan 12, 2010
    Posts:
    402
    Vasica,

    I have this issue as well. For me the framerate in the editor is so bad, my game is basically unplayable but it only happens if I have the gameobject on the character that contains the Behavior Tree component selected in the Heriarchy so that the Behavior Tree component is exposed in the inspector. If I select a different gameobject or select nothing at all so the inspector is empty, my framerate is great. Of course this is a problem because in order to debug your behavior trees in the behavior designer editor, you need to have the gameobject that contains the behavior tree component selected in the hierarchy. My solution is I select the little Lock button at the top of the Behavior Designer Editor. That allows me to select a different gameobject in the Hierarchy or select nothing at all and still have the Behavior Designer Editor window locked to the tree I need to edit.

    I think Justin knows about this problem because I sent him a repo of my project a few weeks ago and it's pretty easy to see the problem. All you have to do is select the character controller gameobject that contains the behavior tree component and the game grinds to halt getting roughly 10 fps.

    Allan
     
  48. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,679
    Hmm.. I just checked our conversation and I don't remember being able to reproduce the framerate drop. It looks like the project that you sent is still uploaded so I'll give that another try and let you know. I'd love to figure out what the cause is.

    @chaneya - if you can profile the editor during low framerate and let me know what the bottleneck is that'd be super helpful.
     
  49. chaneya

    chaneya

    Joined:
    Jan 12, 2010
    Posts:
    402
    Justin,

    That would be great. If you open up BrutePuppetPrefab and select BruteController in the hierarchy so all of the components on the BruteController gameobject are exposed in the inspector along with the Behavior Tree component. Also make sure you have the Behavior Designer editor window open and docked. That should do it. If you let the game play for a little bit and mouse click the Game view screen on the ground to try and move the player around, you should find that the mouse clicks barely function. The framerate is so poor, EasyTouch's events barely register mouse clicks.

    And then if you just select some other gameobject in the hierarchy, you'll have smooth framerate.

    I just assumed the slowdown had something to do with the fact that I'm using a 4K monitor and I use all of my screen real estate and I have very big trees. And it has something to do with the Inspector window exposing the behavior tree component.

    Allan
     
  50. PerunCreative

    PerunCreative

    Joined:
    Nov 2, 2015
    Posts:
    83
    I already tried profiler, but I didn't find method with increased execution time before using scene view and after it was closed. In my case even though the object is not selected in the hierarchy there is a performance drop. In my behaviors I am using ExternalBehaviorTree and the trees have currently around 50-70 tasks.

    I will try to create a repro scene.