Download

AI Patroil for certain time [BT]

Hi,

I am trying to make my AI move for certain time, I’ve tried Time Limit decorator but it’s not working for me.

I want my Ai to patrol for some random time between 2-7 seconds for example, and then move to the other part of my behaviour tree.

Currently my enemy completes the whole path before aborting this task, but I want it to abort when this random time ends.

Any idea of how can I do this?

Thanks!

There are so multiple ways to implement such a logic…

I’d create a BTTask and a Decorator for that.

  • Two BB variables : TargetDestination & bPatrolDone
  • In the BTTask the logic to cycle through patrol points and set TargetDestination + Set a timer to set bPatrolDone = true after 2-7 sec if no timer is running.
  • In the BT : A sequence with a Decorator checking for bPatrolDone set to abort self if true.
  1. BTTask
  2. MoveTo TargetDestination.

Of course you’ll have to Reset bPatrolDone to false when you want your bot to go back to this logic. That would be one way.

Thanks, i’ll try this