Performance: Waypoint systems
MEDIUM IMPACT
This affects frame rate and responsiveness by controlling how often and how many path calculations and object movements occur per frame.
void Update() {
if (ReachedCurrentWaypoint()) {
currentWaypointIndex++;
}
MoveTowards(waypoints[currentWaypointIndex].position);
}void Update() {
foreach (var waypoint in waypoints) {
MoveTowards(waypoint.position);
}
}| Pattern | CPU Usage | Update Frequency | Frame Drops | Verdict |
|---|---|---|---|---|
| Checking all waypoints every frame | High | Every frame | Frequent | [X] Bad |
| Checking only current waypoint | Low | Only when needed | Rare | [OK] Good |