News Forums RAIN General Discussion and Troubleshooting Of Parallels, Sequencers and Timers

This topic contains 2 replies, has 2 voices, and was last updated by  prime 2 years, 2 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #6604

    DrHeinous
    Participant

    So I’ve had a behavior tree ‘SimplePursuit’.
    Root
    ->Parallel
    —->AICategorizeTargets (Custom action, detect and dump targets in to friendly/hostile/neutral lists)
    —->AIChooseTarget (Custom Action, choose a target from the target list)
    —->move (move toward the target using a custom motor).

    This works fine. However, I don’t really want the detect/categorizing running every frame, that’s quite overkill.
    After a bit of research, it seemed like the following should work:

    Root
    ->Parallel
    —->Sequencer
    ——>Timer (1 second delay)
    ——>AICategorizeTargets
    ——>AICHooseTarget
    ->move

    All items set to ‘repeat never’

    I’d have expected the Sequencer and move to execute in parallel. Instead it simply repeats
    the items in the sequencer once per second as I’d like, but the move node is never called. If I
    drag the gameObject within detection range of a target, then the move node executes… but only
    the move node. Once it has a valid target and starts executing, it seems the sequencer never happens again.

    Sequencer set to ‘repeat forever’:
    It sits and detects. The move node never happens.

    Sequencer ‘repeat never’, any node under the sequencer ‘repeat forever’:
    That node (AICategorizeTargets or AICHooseTarget) repeats forever, no other node executes.

    Clearly this isn’t behaving at all as I expect. It seems like the parallel node won’t handle
    the sequencer parallel to the move? Am I approaching this fundamentally wrongly?

    #6606

    DrHeinous
    Participant

    FYI, I have figured out a combination that works:

    Root
    –>Parallel
    —->Sequencer
    ——>Timer (1 second delay)
    ——>AICategorizeTargets
    ——>AICHooseTarget
    –>move

    where the Sequencer is ‘repeat forever’ and the move node is ‘repeat forever’. I believe this was not working because,
    according to the wiki:

    Child nodes in a Parallel will execute until Success or Failure, but will not be automatically restarted by the Parallel. Once a child node has completed, the Parallel may continue executing other child nodes until a Succeed or Fail condition is met.

    Thus both the move and the sequencer need to be ‘repeat forever’ or they are never run after the first pass through the parallel. Is this correct? I suppose I can see the logic of this. Each item in the parallel needs to have completed before any of them can have a second execution, hence the ‘not automatically restarted’, which is quite a different behavior than the other nodes.

    • This reply was modified 2 years, 2 months ago by  DrHeinous. Reason: Added a bit of reasoning about parallels
    #6629

    prime
    Keymaster

    The problem is likely that the first time the move node runs, it does not have a valid target. That’s because choose target may not have run (it has at least 1 second delay). That could cause the move node to fail. If the move node fails, then your parallel could be failing - before the choose target ever happens. Repeat…

    Once you set your move node to repeat forever, it no longer returned failure, which allowed the sequencer time to complete.

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

You must be logged in to reply to this topic.