Using behavior tree to modify Unity ECS entity component data

VaulB

New member
Hi,

I know the ECS version of the behavior tree is under development, but I can't halt my game development because of that. I think it should be possible to use current behavior tree asset, but I don't quite know how. I know there is a way to reference a gameobject in ECS, but how would one reference entity and its components in behavior tree? It would be really helpful to have a sample scene with an example. Has anyone tried to do this?
 
I have not tried doing this so I am hoping that somebody else has experience with it and can respond.

Just for some info I am hoping to get the DOTS version of Behavior Designer out by the (late) summer. I still have a number of features that I need to develop so I can't commit to a specific date yet but I'll post about it when I know. You will not be able to migrate trees from version 1 of Behavior Designer to the DOTS version.
 
Oh that's great! I will definately buy it. It will probably be a few days of work to remake the behavior trees in your new asset, but it will be worth it. I actually got the current behavior tree to work now, but the performance could be better, since I will have at least couple hundred enemies with behavior trees. With around 250 enemies my framerate dropped from 120 to 90. With 0.1s update time i managed to keep it between 100-110. I am doing this in Virtual reality by the way. This is good enough for me now. I can at least create the behavior and test the gameplay loop.
 
Here is how I did it. For some reason I could not paste the code here, so I attached it as txt file. There might be a better way to do it, but at least it works. I wonder if there was a way to set the entity referance directly inside the behavior tree. For example as a global variable.

Note: This implementation works only with spawner. You would need a different approach if the enemy was already at the scene.
 

Attachments

  • BehaviorTreeImplementation.txt
    4 KB · Views: 1
Awesome, and thanks for sharing how you implemented it. The DOTS version will definitely be a lot cleaner :)

It's also funny that you mention wanting to have at least a couple hundred agents. I've been working with agents numbering in the tens or hundreds of thousands so a couple hundred seems extremely low to me right now :D
 
Well I'm still a quite beginner in Unity ECS and game making in general, so I don't know how to optimize everything. Trying to run this game on Quest 3 so, that puts some hard barriers for me. I already implement GPU ECS baker and ECS navigation assets. With those I got around 5000 enemies, with collisions, animations and path finding running steady 120fp on my beefy PC. Didn't even try the limit. On Quest 3 it was steady 70fps with 1000 enemies and still ran 60-70fps with 1300 enemies. I have not yet tried how it works with current behavior tree implementation though, but I have a feeling, that your ECS behavior tree will be very much needed for extra performance.
 
Top