A.I. is never catching up with the player

Hey Aron,

I’m having this issue where my enemies chase the player but always keep some distance behind him, regardless of their speed. I set their acceleration and speed much higher than players and they immediately get in close but then start cruising at the same speed as the player, a bit behind him.

The intention here is for them to catch up with the player and hit him from behind while he’s running.

I got the RVO controller on my enemies and I move them with RichAI’s transform.position (no char controller). I tried disabling the RVO but that didn’t make any difference.
I remember there was a setting “precise slowdown” and thought maybe that’s the culprit but it’s not exposed anymore, not sure if that has something to do with it.

How should I make the enemies catch up?

Hi

Try reducing the slowdown distance variable. The RichAI script will start to slow down when it comes within a certain distance of the target.

There’s no Slowdown Distance. There’s Slowdown Time and End Reached Distance.
I tried setting both to 0 but the behavior didn’t change.
I also found a slowdownDistance variable in the AIPath which was originally at 0.6f; I set that to 0 and still didn’t see the difference.

Ok.

So even though the slowdown distance is zero it will still have to slow down before it reaches the target because the maximum acceleration is finite. If you would increase the acceleration that may change the behavior in other cases though, so you probably don’t want that.

Yeah, I removed that setting because I thought people would pretty much always want to stop at the target point. Not wanting this might be more common than I expected.

To get the previous behavior when ‘preciseSlowdown’ was disabled you can change the lines in MovementUtilities.cs that look like this

var a = (6*deltaPosition - 4*time*currentVelocity)/(time*time);
var q = 6*(time*currentVelocity - 2*deltaPosition)/(time*time*time);

to this

var a = 2*(deltaPosition - time*currentVelocity)/(time*time);
var q = Vector2.zero;

I haven’t tested these changes myself, but hopefully they will make the character just try to reach the target as quickly as possible instead of trying to reach the target with a zero velocity (the difference between slamming into the player and slowing down to precisely stop at the player’s position).

I just uploaded version 4.0.1. If you set the slowdown time on the RichAI component in that version to zero it will not even attempt to slow down.

Where do I download it from? I can only download 3.8.8.1 when I input my invoice number, and there’s a grayed out 4.0.2.

I have sent you a PM.

still on its way I guess, haven’t received it yet

  • Sending you a PM :slight_smile:

Resolved, I installed the new version and setting Slowdown Time to 0 stops the weird tailgating and the enemies are able to catch up and hit the player

1 Like