public sealed class CrowdAgents that follow paths across a NavMesh and stay out of each other's way.
No guide page documents this yet — the page shows what the code says about itself.
Remarks
Four things happen to an agent every update, in this order: it is given a path if it asked for one, it works out which way it would like to go, it is talked out of that by whoever is in the way, and it is moved — across the surface, so that whatever the previous three steps decided, it ends the frame standing somewhere it could have walked to.
That last step is the invariant worth stating on its own: an agent cannot leave the mesh. Steering and avoidance produce a wish, and MoveAlongSurface is what turns the wish into a position. A bug in avoidance makes an agent walk oddly; it cannot make one walk through a wall.
Pathfinding is the expensive part and is done only when something changed — a new destination, or a move that ended outside the corridor. Steering is a string-pull over the corridor and costs a few microseconds; that is what runs every frame for every agent.
Fields and properties (9)
public NavMesh MeshThe mesh the agents walk on.
public NavMeshQuery QueryThe query the crowd plans and moves with.
public NavQueryFilter FilterWhich polygons the agents may use.
public int MaxPathLengthThe longest corridor an agent may hold.
public NavPathQueue PathsWhere the searches happen, a slice at a time.
public int PathIterationsPerUpdateHow many polygon expansions the queue may do per update, across every search in flight.
public int AgentCountHow many agents there are.
public Vector3 SearchExtentsHow far off the mesh a position may be and still be found on it.
public Crowd.AgentEnumerator AgentsEvery live agent, for a caller that wants to walk them — a debug view, a save.
Methods (12)
public Crowd(NavMesh mesh, int maxPathLength = 256, LocalAvoidanceSettings avoidanceSettings = default(LocalAvoidanceSettings))Creates a crowd over a mesh.
public CrowdAgentHandle AddAgent(Vector3 position, CrowdAgentParams parameters)Adds an agent.
public bool RemoveAgent(CrowdAgentHandle handle)Removes an agent.
public bool SetTarget(CrowdAgentHandle handle, Vector3 target)Tells an agent where to go.
public bool SetTarget(CrowdAgentHandle handle, NavPolyRef poly, Vector3 point)Tells an agent to go to a polygon it has already been given.
public bool ClearTarget(CrowdAgentHandle handle)Tells an agent to stop.
public bool TryGetHandle(int index, out CrowdAgentHandle handle)The handle for a slot, if it holds a live agent.
public bool TryGetParams(CrowdAgentHandle handle, out CrowdAgentParams parameters)Reads an agent's parameters back.
public bool SetParams(CrowdAgentHandle handle, CrowdAgentParams parameters)Changes an agent's parameters.
public bool TryGetState(CrowdAgentHandle handle, out CrowdAgentState state)Reads an agent back.
public bool Teleport(CrowdAgentHandle handle, Vector3 position)Moves an agent somewhere without walking it there.
public void Update(float deltaTime)Steers and moves every agent.
Used by (12)
- CrowdBenchmarksVixen.Benchmarks.Navigation
- AgentEnumeratorVixen.Navigation
- CrowdRetargetTestsVixen.Navigation.Tests
- CrowdTestsVixen.Navigation.Tests
- NavMeshDebugDrawVixen.Navigation
- NavMeshDebugDrawTestsVixen.Navigation.Tests
- NavPathQueueJobTestsVixen.Navigation.Tests
- NavPathQueueTestsVixen.Navigation.Tests
- NavigationAllocationTestsVixen.Navigation.Tests
- NavigationSystemVixen.Navigation
- NavigationSystemTestsVixen.Navigation.Tests
- OffMeshConnectionTestsVixen.Navigation.Tests