• Advertisement
  • Popular Tags

  • Popular Now

  • Advertisement
  • Similar Content

    • By ethancodes
      I'm having a weird issue with detecting a collision. I've tried everything I could find online but nothing seems to work. I have a brick object. It has a 2D Collider attached and I have also attached a 2D Rigidbody on it. I also have an EndScreen 2D Collider. The EndScreen 2D collider is tagged with "EndScreen". I am trying to detect when a brick collides with the end screen collider and simply print "game over" in the console. 
      This is my current code for this part of the program, it is attached to the bricks:
      void OnCollisionEnter (Collision2D collision) { if (collision.gameObject.tag == "EndScreen") { Debug.Log("Game over"); } } Several things have happened depending on the set up. If I have the rigidbody 2D set as static, my ball object can still collide with the bricks, but I get no Log message. If I set it to Kinematic or Dynamic, I get absolutely no interaction between the ball and the bricks, and nothing when the bricks pass through the collider. I have tried to set the collider to a trigger and use OnTriggerEnter2D, no change. I have tried to put the rigidbody on the EndScreen object and tried to set it's body type to all 3 settings, no change. The only thing I can think of that I have not done is put the script on the EndScreen object and switch the tag to the bricks. The reason I have not done this is because I will have several types of bricks, some of which will have different tags. 
       
      Please tell me somebody can see what I'm doing wrong here, because I'm losing my mind over something I feel should be ridiculously simple. Thanks.
    • By Sandman Academy
      Downloadable at:
      https://virva.itch.io/sandman-academy
      https://gamejolt.com/games/sandmanacademy/329088
      https://www.indiexpo.net/en/games/sandman-academy
      https://www.gamefront.com/@sandmanacademy
      http://www.indiedb.com/games/sandman-academy
    • By Sandman Academy
      Downloadable at:
      https://virva.itch.io/sandman-academy
      https://gamejolt.com/games/sandmanacademy/329088
      https://www.indiexpo.net/en/games/sandman-academy
      https://www.gamefront.com/@sandmanacademy
      http://www.indiedb.com/games/sandman-academy
    • By Sandman Academy
      Downloadable at:
      https://virva.itch.io/sandman-academy
      https://gamejolt.com/games/sandmanacademy/329088
      https://www.indiexpo.net/en/games/sandman-academy
      https://www.gamefront.com/@sandmanacademy
      http://www.indiedb.com/games/sandman-academy
    • By Sandman Academy
      Downloadable at:
      https://virva.itch.io/sandman-academy
      https://gamejolt.com/games/sandmanacademy/329088
      https://www.indiexpo.net/en/games/sandman-academy
      https://www.gamefront.com/@sandmanacademy
      http://www.indiedb.com/games/sandman-academy
  • Advertisement
  • Advertisement
Sign in to follow this  

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

This topic is 727 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