Jump to content
  • Advertisement
Sign in to follow this  
Andrew Blem

Unity How to implement a Behavior tree(prefarably in Unity 3D)

This topic is 817 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a state machine I want to implement as a behavior tree. I now have an understanding of how they work but I cant seem to find an implementation of a behavior tree. I have implemented a simple one using a plug-in called Behavior Machine but the problem I have with it is I feel like it limits me just as it did when I used it for making my FSM until i implemented my own. The other problem I have is it is difficult to implement my own nodes and control which part executes(optimization). Any idea on where I can find a good tutorial on how I can do this preferably on Unity and in C# or in java. Or where I can find a good library with proper documentation because the one I found on Github or other sights are buggy or its just some classes with no documentation. Your help will be greatly appreciated.

Share this post


Link to post
Share on other sites
Advertisement

A Tutorial will only give you the down to earth basics of it's implementation (and usually not a very good one). Tell us what's confusing you, what you want to add and we can help you from there. Annd... any behavior tree implementation you look for is either going to be something you buy, or something that's not C# or translates very well.

Share this post


Link to post
Share on other sites

? It's just a tree with nodes for choices and state IDs for leaves. You can certainly implement that in C#.

 

Why are you thinking that this needs to be optimized though? What are you using it for and how deep is the tree?

Share this post


Link to post
Share on other sites

Well when i implemented my FSM i experienced performance issues because some functions where being called ever frame so i had to create another "CustomUpdate"  function that I can control its execution frequency like tell it to execute 10 times every second which increased my performance. Since I want to convert that same FSM to a behavior tree I thought I might experience some performance issue. I want to use it to create an A.I for a soccer game so that I can ask someone to play the game and see if they can see any difference between a team implementing the behavior tree or the FSM. The thing now is I want to implement my own tree and a heads up on how I can do it will be appreciated.

Share this post


Link to post
Share on other sites

 The thing now is I want to implement my own tree and a heads up on how I can do it will be appreciated.

 

Have you seen the talks/slides on this site? They might help.

 

A behavior tree core implementation is actually fairly simple. I mean, I wrote one a while back based on info I learned from the above reference site - I could dig that code up and give it to you - but looking at Behavior Machine in the Unity asset store, it does everything mine did and much more (and appears to plug nicely into Unity). What's wrong with it exactly? How is it limiting you?

 

The hard part is modelling the world and somehow distilling that into nodes in a BT. And you won't find any implementation that does that, because it will be specific to your game. So maybe you're looking for tutorials that help explain how to do that, or concrete examples of complex AI implemented using behavior trees? Let me know if you find any good info on that!

Share this post


Link to post
Share on other sites

Rain AI might be what you're looking for.

It has a great interface for creating behaviour trees and it's free.

http://rivaltheory.com/rain/

 

EDIT: I'm not sure this was what you were looking for, but I've used it myself and really liked it.

Edited by stonecompass

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!