Performance: Pathfinding basics
MEDIUM IMPACT
Pathfinding affects how fast a game character or object can find a route, impacting frame rate and responsiveness.
void FindPath(Vector3 start, Vector3 end) {
// Use A* algorithm with heuristic
// Prioritize nodes closer to target
// Early pruning of bad paths
// Returns shortest path efficiently
}void FindPath(Vector3 start, Vector3 end) {
// Brute force search checking all possible paths
List<Vector3> allPaths = new List<Vector3>();
// ... very expensive recursive search without pruning
// returns first found path
}| Pattern | CPU Usage | Frame Delay | Responsiveness | Verdict |
|---|---|---|---|---|
| Brute force search | High (explores many nodes) | High (blocks frames) | Poor (input lag) | [X] Bad |
| A* algorithm with heuristic | Low (prunes paths) | Low (fast frames) | Good (smooth input) | [OK] Good |