Question about BT node arrangement

NodeCanvas Forums General Discussion Question about BT node arrangement

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

    Hi, I’m working on a multi agent system in which I want to make the agents iterate through a list of needs and satisfy them. In the example on the attached picture you see how I have tried to accomplish that. The problem is, that as soon as the right condition (thirst < small value) is met, the child sequencer instantly jumps back to the left condition (thirst >= big value) instead of returning success to the main sequencer, so it could go on to the hunger part. Even though I think I know why this is happening, I can’t figure out how to arrange this properly.

    I also tried to replace the main sequencer with other Composite nodes, i.e. a priority selector (high to low from left to right) but nothing worked so far.

    I’d be glad about any help!

    Attachments:
    You must be logged in to view attached files.
    #11273
    chocolacode
    Participant

    Hi There jonc,

    I was trying to analyze you scenario and I am not sure what of the following scenarios you trying to accomplish, can you please clarify?…
    if thirst >= 80.2 OR thirst < 24.26 then Owner.Drink()
    or
    if thirst >= 80.2 then owner.Drink()
    if thirst < 24.26 then –>> jump to check Hunger values

    #11274
    jonc
    Participant

    Of course 🙂

    What I’m trying to achieve is that the agent works through a very simple checklist of needs and when one need is satisfied it can look at the next, so very rudimentary. Let’s say thirst & hunger are at 100 and stamina is at 0 which equals my scenario in Unity.

    That’s what is happening:

    Seq1 (Thirst Sequence): thirst >= 80 ? true -> owner.Drink() (which doesn’t return success by itself it just decreases the thirst value, that’s the reason for the last condition) (which returns success instantly) -> thirst < 20 ? We drank enough so return success, which it wont, or so fast, I can’t see it and it jumps back to thirst >= 80 ? which is false and then it just hangs there until the agent is thirsty again.

    So, the main sequencer works through the thirst sequence again until there is no Drinkable left in the scene, it ignores hunger and stamina completely.

    I’m very excited about behaviour trees and grateful for any lecture!

    EDIT: Just wanted to clarify, the Owner.Drink() method is no NodeCanvas Action and it indeed returns success instantly, then it goes on to the “thirst < 20 ?” condition.

    #11275
    chocolacode
    Participant

    Hello ,

    Composite sequencers work that way.. and that is expected.You get more details in the node description help: “Execute the child nodes in order or randonly and return Success if all children return Success, else return Failure. If is Dynamic, higher priority child status is revaluated. If a child returns Failure the Sequencer will bail out immediately in Failure too.”

    I would suggest you try (for the Main Composite) with some other composite nodes, like: Selector or Flip Selector or Probability selector, they will give you similar results,

    you might want to check the sample scene that come with Nodecanvas package called “imaginary cat”. that is a very similar example of what you are trying to accomplish,

    cheers!

    #11286
    jonc
    Participant

    Thank you very much! The “Imaginary Cat” example was indeed very helpful! The trick was to use a selector instead of a sequencer as the main composite node. I should have really had a look at the examples earlier.

    Back to study! 😀

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