Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

A.I. Behavior Tree Structure

Discussion in 'Scripting' started by LiberLogic969, Apr 8, 2015.

  1. LiberLogic969

    LiberLogic969

    Joined:
    Jun 29, 2014
    Posts:
    138
    I'm trying to create a very simple behavior tree for my AI and I'm having trouble figuring out a straight forward way of structuring it within Unity using the component system. I can't think of any other way to do it besides making Nodes (like Sequence, Selector, etc.) components and creating the actual tree using a hierarchy of GameObjects on the Enemies... if that makes any sense at all... This approach seems really sloppy and bloated to me... Does anyone have any other ideas on how to set something like this up within Unity?

    Also, I've tried a few Asset Store packages but they severely lack documentation so I think I'm on my own with this one.
     
  2. Strategos

    Strategos

    Joined:
    Aug 24, 2012
    Posts:
    255
  3. _met44

    _met44

    Joined:
    Jun 1, 2013
    Posts:
    633
    You can create C# classes/structs that don't derive from MonoBehavior so you're free to create whatever data structure you want...

    You'll end up with a reference to the structure in a MonoBehavior since that's how unity works but beside that you're free to do as you fancy (except with threads, there you're limited to only using your own code)
     
  4. MysterySoftware

    MysterySoftware

    Joined:
    Sep 18, 2014
    Posts:
    46