News Forums RAIN General Discussion and Troubleshooting "Break" the sequencer

This topic contains 1 reply, has 2 voices, and was last updated by  Sigil 3 months, 3 weeks ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #39385

    ngtrhieu0011
    Participant

    Hi,

    Currently I have a simple AI which look like this:

    - Selector [root]
    — Chase player and attack [Sequence]
    ——- Find player [Action - custom - failure when cannot detect player]
    ——- <to be implemented>
    — Wander [Sequence]
    ——- Random wander point [Action - custom]
    ——- Move to wander point [Action - custom]
    ——- Wait a bit [Action - timer]

    The idea is, when the AI not detecting the player, it will on “Wander” state and keep moving around. However, when the player is detected, it should goes into the “Chase” state and chase down the player. However, the AI will not detect player when it is in the middle of running the Wander sequence (either when it is moving or waiting). Is there a way to “break” the sequence?

    Another way to ask: is there a way to force RAIN AI to start again at the root at every tick instead?

    ——-
    P.s: I am aware of the method of using parallel node as showing in this thread http://rivaltheory.com/forums/topic/example-xml-files. However, I feel it would later complicating the tree with so many nested parallel group

    • This topic was modified 3 months, 3 weeks ago by  ngtrhieu0011.
    #39396

    Sigil
    Keymaster

    One option is to put the parallel higher up and use a constraint to interrupt your sequencer (real sparse here, so if you have trouble I can go over it more):

    root
       parallel
          detect (repeat: forever, form variable: _myTarget)
          selector
             constraint (constraint: _myTarget == null)
                ... do some wandering (I'm assuming this never fails in this example)
             sequencer
                ... do some chasing

    The constraint acts like a sequencer, but it always evaluates the constraint and makes sure it is true before running its children. If it ever goes false it will “interrupt” its children.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.