AI Move with specific condition

Hi,

I’m new here, sorry for noob question. I have problem trying to create a certain behavior tree. The logic is as follow:

  1. Check until player is in range (500) → I use task in here, I know I can use perception, perhaps later
  2. If player in 500 range, get the player position, and move to that position.
  3. If the AI is in range of that position, OR in range to current player position, stop and do attack.
  4. wait for 3 second.

Step 1 and 4 is solved, but step 2 and 3 is a little bit tricky due to the OR clause. In step 1, I save the player actor as a value in billboard and a simple Move To task will do the trick. But if the player moves away, the enemy won’t stop following the player (which I don’t want to do since its destination is the last known location before it moves). But if I save the location in step 1, the AI will keep moving to that location even if the player moves closer.

So I thought I should create my own task where while moving, the player will check both last known location and player location. But I got stuck with Simple Move and Move does not allow check custom range (only 1 input for radius). Is there a way to inject self-made conditions to interrupt move to/simple move to?

Thank you in advance

Can we have a look at your behaviour tree? We need more information otherwise, it’s hard to help you.

1 Like

Create a Service that checks the player range. If it’s within attack range, have it set a blackboard boolean to do attack, otherwise if in sight range, set a blackboard to a move target, otherwise clear the move target.

Then have a branch with a decorator that checks for attack, one that hcecks for move, and one that does whatever you’re supposed to do when there’s no attack or move to target

1 Like

Services do the trick. Thanks, eblade

56legion It’s solved. Thanks, anyway.

edit: kinda new here in this forum. How do you set the topic as solved? Or is it automatically solved?

1 Like