Performance: NavMesh Agent component
MEDIUM IMPACT
This affects the runtime navigation and pathfinding performance, impacting frame rate and responsiveness during gameplay.
foreach (var agent in agents) { if (Vector3.Distance(agent.destination, target.position) > threshold) { agent.SetDestination(target.position); } }
foreach (var agent in agents) { agent.SetDestination(target.position); }| Pattern | CPU Usage | Pathfinding Calls | Frame Impact | Verdict |
|---|---|---|---|---|
| SetDestination every frame for many agents | High | Many per frame | Frame drops and stutter | [X] Bad |
| SetDestination only on significant target move | Low to Medium | Few per frame | Smooth frame rate | [OK] Good |