How to stop NPCs from walking in a line?

This may be a dumb question, or one already answered, but how can I make my NPCs walk offset from each other? My enemies are walking into each other or in a straight line to get to their common destination. I want them to act more like a squad, being more spread out to get to their point. Is there like a spread variable for the navmesh?

I am using the nav mesh agent to control where the NPCs are head towards, this is my script:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;

public class TargetFlag : MonoBehaviour {

public GameObject player;
NavMeshAgent agent;

// Use this for initialization
void Start () 
{
	player = GameObject.Find ("Flag");
	agent = gameObject.GetComponent<NavMeshAgent> ();
}

// Update is called once per frame
void Update () 
{
	agent.SetDestination (player.transform.position);
}

}

Please tell me if there is more information I need to provide, thx :slight_smile:

If this question has been answered, would you mind sharing the link?

Have you found a solution to this problem? I am facing the same problem and can’t find a way to solve it

You could make use of “Flocking”, where objects look at their closest neighbors to determine there own position. The direction they are going is based on the global direction of the group. There are a lot of videos and tutorials on this subject.