How do you usually start your AI/NPC behaviour trees?

NodeCanvas Forums General Discussion How do you usually start your AI/NPC behaviour trees?

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #12220
    jonc
    Participant

    Hello,

    I’m stuck with my AI tree and I really need help to advance any further. Could you guys please tell me, what your AI trees are basically made of?

    Some of my questions are:

    Is there a common practice, to start out NPC behaviour trees?

    Do you place FSMs on the very top or a dynamic sequencer?

    What do you do to generalize behaviours, I.e. when you have a billion “Goto -> Interact (Use Potion, open chest, attack)” actions of different kinds? Do you make heavy use of generic types?

    Do you redirect to a “goto”-branch as soon as the AI needs to move somewhere (If yes, how?) or do you prefer adding it over and over again for every action?

    How do you make the AI reliably fulfill whole queues of actions on their own?

    I’m thankful for any advice really, because I feel like running against a wall with my current BT. Screenshots of small informative BTs are also very welcome.

    #12228
    Gavalakis
    Keymaster

    Hello,

    The first thing I always suggest to everyone, is to avoid creating behaviour trees with a lot of low-level actions (like the ones included) and instead either:

    1) Create high-level actions to use, or…
    2) Create your code functions as you normally would and use Script Control tasks to call these functions you’ve already implemented, or…
    3) Create reusable Behaviour Tree assets for use as SubTrees.

    In all of the above cases, (custom actions, implemented functions, SubTrees) these should ideally implement high-level functionality and we should be using the agent’s root Behaviour Tree to design *when* these happen, rather than *what* happens. If GoTo is part of all “interactions” for example, then ideally GoTo should not be a different action, but rather part of these high-level nodes.

    It is also generally a very good idea to have an FSM as the root system (instead of a Dynamic Sequencer), if having different and definitely distinctive states for the agent does indeed makes sense.

    This is of course generally a very open subject and heavily relies on what the game is and the agent needs to do, but I hope the above pointers help somehow. If you want to elaborate on any of the above, or more specifically to some of your questions, let me know some more details about each subject and maybe what type of game it is that you are making, and I will do my best to help further.
    What do you mean by “generalize” behaviours for example a bit more specifically by the way?

    Once again, the main rule of thumb (at least for me), is to design the trees for *when* stuff happens, not for *what* or *how* they do 🙂

    Thanks!

    Join us on Discord: https://discord.gg/97q2Rjh

    #12238
    jonc
    Participant

    Hi Gavalakis, thanks for taking the time to help!

    May be “generalizing” was the wrong wording and poor choice of timing in my opening post. I actually meant to ask, what people do to keep their trees clean and easy readable and I assume part of that would be, for instance, to redirect to a “Goto” hook somewhere in the tree or would it be a subtree? I don’t know. That’s where I get lost. :-S

    Let’s say our AI has many actions which involve a “moving to” action followed by a “interact” action. How do you handle that duplicate “goto” code best?

    Gavalakis, would you mind showing me a little high-level “what-when” example? I’m just not involved enough to understand.

    As for the game I am working on. It’s gonna be an mmorpg-ish singleplayer open world rpg, of course with a strong focus on the NPCs, which will have daily routines, so they’ll have to do alot of actions, like “moving to” bed and “sleep”. “moving close” to deer and “shoot”, “moving to” a well and “fetch water”. All controlled by some sort of scheduler.

    But that’s a long road in terms of Behaviour Tree AI for me, because I’m not even able to make a simple agent, who attacks targets which come too close and then goes into wandering mode if target is dead or went out of chase range (using Unity NavMesh).

    Thanks for anything useful you can throw at me!

    #12244
    arachnidjacob
    Participant

    I posted pics of my current working iteration for our submarine game here

    Take heart, behaviourtrees are bit obtuse to get into at first ( i gave up the first time i tried with a different plugin), but once you start understanding the logic it opens up.

    #12248
    jonc
    Participant

    Thanks very much Jacob! These trees look awesome but they are way more complicated than what I’d be able to grasp right now. I think I’ll start from scratch today and keep it as simple as possible. May be I’ll start off by making the AI attack each other at a certain distance until one dies, then I might build on top of that overly simple construct.

    Still, if anyone cares to drop by and leave a hint on how to handle NPC routines or BTs in general, that’d be great!

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.