public sealed class LocalAvoidancePicks the velocity that gets closest to what an agent wants without walking into anybody.
No guide page documents this yet — the page shows what the code says about itself.
Remarks
Reciprocal velocity obstacles, sampled. Candidate velocities are scored by how far they are from the desired one, how far from the current one, and how soon they would end in a collision; the best-scoring candidate wins. The reciprocal part is that each agent assumes the other will take half the responsibility for getting out of the way — the relative velocity used in the collision test is 2v - vₐ - v♭ — which is what stops two agents from both dodging the whole distance and oscillating.
Sampling rather than solving. The exact answer is the boundary of a union of cones and is both harder to compute and no better in practice: the agent re-decides sixty times a second, so a slightly-wrong velocity for one frame is invisible, and a sampler degrades gracefully in the crowded case where the exact answer is "there is no admissible velocity".
Stateless, so one instance serves every agent, and nothing here allocates.
Fields and properties (1)
public LocalAvoidanceSettings SettingsThe weights and sample counts in use.
Methods (2)
public LocalAvoidance(LocalAvoidanceSettings settings = default(LocalAvoidanceSettings))Creates an avoidance sampler.
public Vector3 Sample(Vector3 position, float radius, Vector3 velocity, Vector3 desired, float maxSpeed, ReadOnlySpan<AvoidanceNeighbour> neighbours)Chooses a velocity.
Used by (1)
- CrowdVixen.Navigation