recast-navigation-js
    Preparing search index...

    Class Crowd

    Index
    • Parameters

      • navMesh: NavMesh

        the navmesh the crowd will use for planning

      • param1: CrowdParams

        the crowd parameters

      Returns Crowd

      const crowd = new Crowd(navMesh, {
      maxAgents: 100,
      maxAgentRadius: 1,
      });
    agents: { [idx: string]: CrowdAgent }

    The agents in the crowd.

    navMesh: NavMesh

    The NavMesh the crowd is interacting with.

    navMeshQuery: NavMeshQuery

    The NavMeshQuery used to find nearest polys for commands

    raw: dtCrowd
    • Destroys the crowd.

      Returns void

    • Returns the number of active agents in the crowd.

      Returns number

    • Gets the agent for the specified index, or null if no agent has the given index.

      Parameters

      • agentIndex: number

      Returns CrowdAgent | null

    • Returns the maximum number of agents that can be managed by the crowd.

      Returns number

    • Returns all the agents managed by the crowd.

      Returns CrowdAgent[]

    • Gets the query filter for the specified index.

      Parameters

      • filterIndex: number

        the index of the query filter to retrieve, (min 0, max 15)

      Returns QueryFilter

      the query filter

    • Removes the agent from the crowd.

      Parameters

      Returns void

    • Steps the crowd forward in time with a fixed time step.

      There are two modes. The simple mode is fixed timestepping without interpolation. In this case you only use the first argument. The second case uses interpolation. In that you also provide the time since the function was last used, as well as the maximum fixed timesteps to take.

      Parameters

      • dt: number

        The fixed time step size to use.

      • OptionaltimeSinceLastCalled: number

        The time elapsed since the function was last called.

      • OptionalmaxSubSteps: number

        Maximum number of fixed steps to take per function call.

      Returns void

      const deltaTime = 1 / 60;
      crowd.update(deltaTime);
      crowd.update(timeSinceLastUpdate);
      
      const deltaTime = 1 / 60;
      const maxSubSteps = 10;
      crowd.update(deltaTime, timeSinceLastUpdate, maxSubSteps);

      console.log(agent.interpolatedPosition);