Prevent overlap with FollowerEntity and CharacterController

Hello!

I am making a Hades-style game where all the enemies use this package for their pathfinding / movement logic. The main character is player controlled without pathfinding using simple the CharacterController script.

I am running into issues where the enemies don’t respect the collision bounds of the main character. If the player is moving, the player collides with the enemies correctly if I put a capsule collider on the enemy. But if the player stops moving the enemies can just walk through to the centerpoint of the player.

I’ve tried using RVO on the Main character, but that resulted in the player being able to push the enemies which is not desired (even if I set the priority correctly).

I also tried using NavMeshCut, which made it so that enemies don’t walk into the player, but sometimes walk around the player in undesirable ways.

The desired behavior is that enemies who are running towards the player (to attack them), will stop when their radius collides with the radius of the player. If the player runs into an enemy, it should be no different than running into a wall (just block forward movement)

Curious if anyone has suggestions! Thanks so much!

Which script are you referencing here?

I’m gonna tag Aron on this one because while testing this I noticed that the AIPath agents with an RVO don’t overlap much if at all. FollowerEntity is much more prone to it, it seems. I wouldn’t really know why though or how to get FollowerEntity (or any movement script) to not overlap without RVO, especially.

This is Unity’s built in character controller script. Unity - Scripting API: CharacterController

Happy to switch to something custom if there’s no clear path to it working with it.

As an update, I found some improvement by making the movements towards the player target a position that subtracts the player / enemies radius from the target destination. This works to prevent overlap in most cases, but not if the enemy is pathing towards another location that’s not the player.

Maybe I’m missing something, but can’t you just increase the stopping distance?

Specifically for avoiding the destination, if it’s the player, this works! If OP wants just the destination to be not collided with, this is a good answer :+1:

Changing the stopping distance is very similar to what I have now (setting the destination to be outside the player’s radius). But it doesn’t solve the enemy walking through the player if they are pathing somewhere else / towards another player. I suppose maybe a combination of what I have +NavMeshCut around the player would get me the desired behavior. Will try and report back.

Assuming you don’t have a very large number of agents (thousands), you can potentially check in script each frame to see if both:

  1. the square distance to the player is less than some constant, AND

  2. the angle to the player is within a certain tolerance of the angle to their objective.

If both conditions are true, then stop the agent. When one or the other condition becomes untrue, start it up again.