-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNavMeshPathfindingIterationsPerFrame.cs
More file actions
27 lines (25 loc) · 1.09 KB
/
NavMeshPathfindingIterationsPerFrame.cs
File metadata and controls
27 lines (25 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// Unity only calculates 'n' navmesh pathfinding iterations per frame. The
// default value of 100 is fine for small projects, but an MMO with huge amounts
// of agents will require more iterations per frame to avoid movement delays.
//
// For now we simply increase that number in Awake once.
// In the future we will be able to set the iteration number per agent:
// https://forum.unity3d.com/threads/pathfindingiterationsperframe-for-bigger-games-should-be-per-agent.482699/
//
// Note: we could already use Update to set iterations to players.count*multiplier,
// but it's not that much better since one player could still delay all other
// player's path calculations.
using UnityEngine;
using UnityEngine.AI;
namespace uMMORPG
{
public class NavMeshPathfindingIterationsPerFrame : MonoBehaviour
{
public int iterations = 100; // default
void Awake()
{
Debug.Log("Setting NavMesh Pathfinding Iterations Per Frame from " + NavMesh.pathfindingIterationsPerFrame + " to " + iterations);
NavMesh.pathfindingIterationsPerFrame = iterations;
}
}
}