Search Results for

    Show / Hide Table of Contents

    Crowds Setup

    Important

    This page explains the functionalities of the Agents Navigation - Crowds extension package.

    This tutorial will explain how to do minimal setup for agent crowd flow.

    Firstly, you will need to create a Crowd Surface. This will be the walkable surface area for your crowd agents. You can easily do this by right-clicking in Unity's Hierarchy View and selecting AI > Crowd Surface. If your project is 3D, it is recommended to rotate the surface by 90 degrees around the x-axis.

    Next, you will be creating a Crowd Group. This will represent a single group where agents will belong. You can easily do this by right-clicking in Unity's Hierarchy View and selecting AI > Crowd Group. Make sure it references your newly created surface.

    Now, you need to create an agent. This again can be done by right-clicking in Unity's Hierarchy View and selecting AI > Agent Cylinder/Circle. As this menu item creates minimal setup agent, you will need a few additional components to add. Agent Crowd Pathing will include the agent to participate in crowd flow with a specific group, and Agent Collider will enable collision with other nearby agents. Collider is needed because crowd pathing does not guarantee agents won't overlap in all cases.

    Finally, you need to set a goal for your crowd group. If the crowd group has Goal Source set to Agent Destination, the group will collect all its agent destinations and will construct a global goal out of it. For how to set agent destination, you can refer to another tutorial Set Destination.

    The alternative way is to pass goals array directly into the group.

    Hybrid:

    var goals = new float3[] { a, b, c };
    var group = GetComponent<CrowdGroupAuthoring>();
    group.SetGoals(goals)
    

    Entities:

    var goals = new float3[] { a, b, c };
    var group = world.EntityManager.GetComponentData<CrowdGroupFlow>(entity);
    group.Flow.ClearGoals();
    foreach (float3 goal in goals)
    {
        group.Flow.AddGoal(goal);
    }
    
    In This Article
    Back to top Copyright © ProjectDawn.
    Generated by DocFX