Make the enemy surround the player?

Hello, im pretty newby into the AI so here comes my question.
I use NavMesh into my enemies so they can chase the player, but I have a problem, they only will follow him.

I know that this is what I should be expecting with doing that (The target is just the player), but I want a more complex pattern, I would like to make them not take only the short path to the player but sometimes other paths, but I dont know how to do that or what I need.

Maybe I should not be using NavMesh? There is another way to do this?

My map is something like a COD zombies map, some rooms interconnected.

I have searching but didnt found nothing about AI like this, any help would be appreciate.

Thanks in advantaje.

I haven’t used NavMesh yet, but how about setting random target positions for the enemies around the player position.
Something like this, assuming playerPos is your player’s position in 3D space:

Vector3 GetRandomTargetPos(float minRadius, float maxRadius)
{
    Vector2 rndPos = Random.insideUnitCircle * (maxRadius - minRadius);
    rndPos += rndPos.normalized * minRadius;
    return new Vector3(playerPos.x + rndPos.x, playerPos.y, playerPos.z + rndPos.y);
}

And maybe check if the returned position is valid (not blocked etc), otherwise get a new random position.

The problem its that I would like to make them choose go though one room on another, random the path, not just follow.

You’ll probably want to start by hard coding some of the different paths using waypoints and randomly select one of the paths when the zombie is too far away to run in a straight line to the player. Once you have that working, you can start making it more complicated or general. The idea behind a waypoint path is that you have the zombie path to the first point in the path, then when it arrives start pathing to the next point and so on. To start with, just assume the player is always in the same room and doesn’t change rooms. It’s a bad assumption, but it’s a good starting point.

You could define a couple of possible paths as waypoint lists, with each list containing a set of Vector3s. An enemy would then go to each position in a list in consecutive order. Sort of like patrolling, but if you check for proximity to the player, an enemy could leave it’s path and follow the player directly.

The problem with that would be that how the enemy would know in which direction of the path has he to go?
The only think that I think that could solve that would be checking the distance to the player for that waypoint, right?

Yeah, but I need the enmey always following the player, it cant be patrolling, maybe mbaske answer would be a better option

@alexxjaz If you are comfortable working with graphs, then you could make each room a graph node and then use a shortest-path algorithm to send zombies to each of the nodes adjacent to the player’s node before running at the player.

Thus is a pretty complex problem, maybe you can get some ideas from my devlog here

Any hint of how its that done?