Handling Multiple Enemies in a VR Dungeon Crawler

Hello everyone,

So I’ve been making a multiplayer VR dungeon crawler for the past year or so and just recently made the switch to A* Pathfinding Pro. I’ve been using Recast graphs as they are the fastest for the randomized dungeons, but I have ran into some problems with multiple enemies. Here’s a picture to help you understand my problem:

Although the enemies have the NavMesh Cut component on them, they don’t seem to go around the other enemies, they just walk into and stay inside eachother. I’ve tried just enabling collision between them and that makes for a glitchy and dissapointing experience since they are all trying to go to the same place. Any advice? Here’s a picture to show what I want:

Thank you,
Mike

Hi

You cannot use navmesh cutting for agents that themselves are going to use pathfinding. If you do this then you will always remove the navmesh where the agents are so they will always think they are in an invalid position and will try to move back to the navmesh as quickly as possible.

You might want to try local avoidance instead (see RVO example scenes)?
Most games (e.g SC2 just to name one) use some kind of local avoidance instead of planning around agents.

Also. It looks like the shader for the navmesh is broken (it should not be pink). What version are you using?

Alright, so I have now implemented local avoidance and the enemies now don’t walk through eachother while patrolling, but they still do it while fighting… here’s a code snippet of the enemy script:

var rvoTarget = (waypoint - transform.position).normalized * remainingDistance + transform.position;
		// When within [slowdownDistance] units from the target, use a progressively lower speed
		var desiredSpeed = Mathf.Clamp01(remainingDistance / slowdownDistance) * 10f;
		Debug.DrawLine(transform.position, waypoint, Color.red);

		rvo.SetTarget(rvoTarget, desiredSpeed, 10f);

		float angle;
		angle = FindAngle (transform.forward, rvoTarget - transform.position, transform.up);

		if (!attacking) {
			//only setup animator if NO attack
			animSetup.Setup (speed * (speedModifier / 2), angle);
			//Always move, but don't always setup the animator...
			var movementDelta = rvo.CalculateMovementDelta (Time.deltaTime);
			transform.position += movementDelta * 0.1f * speedModifier;
		}

They still do what is pictured in the photos in my original post, any ideas on how to approach this? By the way, I just reinstalled the assets and it fixed the material problem.

Thanks,
Mike

Hi

This is likely because if they are attacking you are simply ignoring the input from the local avoidance system, but the local avoidance system will assume that the character was moved with that velocity until the next simulation step.
To solve this I recommend that you set the ‘locked’ field on the RVOController to true while attacking.

rvo.locked = attacking;