Handling if true X else Y?

NodeCanvas Forums General Discussion Handling if true X else Y?

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #9306

    I am new to behaviour trees, so I apologise for such a simple question but lets say I have a custom condition which returns true or false.

    Now if its true I may want to do X if its false I would want to do Y, how do I express that? as in the demos I have seen so far it always just seems to be if true X, there never really seems to be an else Y and I was just wondering how I would achieve that?

    #9309

    Hi,
    This is one solution for it!

    #9308

    What type is your condition node there (away from unity to check atm) as my condition nodes did not have any output to link from, so I assume that is where I went wrong, I did not want a Condition node but some other node type which houses the condition.

    #9307
    Gavalakis
    Keymaster

    There are more than one ways to go with if-then-else in Behaviour Trees. The tree ‘onerain88’ posted is one way. It uses an ‘Accessor Decorator’, which can be assigned a condition Task and will execute it’s child node ‘x’ only if that condition assigned is true, else it will return Failure immediately (and thus the Selector will execute the next child ‘y’).

    Another way would be the attached one. Both ways do the same, but personaly I would recomment using the Accessor Decorator 🙂

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

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