diff --git a/Assets/Prefabs/GameManager.prefab b/Assets/Prefabs/GameManager.prefab index 45801e02..fd34afec 100644 --- a/Assets/Prefabs/GameManager.prefab +++ b/Assets/Prefabs/GameManager.prefab @@ -549,3 +549,4 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: m_maxTimePerFrameMs: 0 + m_navMeshPathfindingIterationsPerFrame: 1000 diff --git a/Assets/Scripts/Behaviours/PathfindingManager.cs b/Assets/Scripts/Behaviours/PathfindingManager.cs index 60cbbb04..c8f1b0c3 100644 --- a/Assets/Scripts/Behaviours/PathfindingManager.cs +++ b/Assets/Scripts/Behaviours/PathfindingManager.cs @@ -6,6 +6,7 @@ using System.Diagnostics; using System.Linq; using System.Reflection; using UnityEngine; +using UnityEngine.AI; namespace SanAndreasUnity.Behaviours { @@ -78,11 +79,15 @@ namespace SanAndreasUnity.Behaviours private static readonly FieldInfo s_leftNodeField = s_nodeType.GetField("k__BackingField", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); private static readonly FieldInfo s_itemNodeField = s_nodeType.GetField("k__BackingField", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); + [SerializeField] private int m_navMeshPathfindingIterationsPerFrame = 100; + protected override void OnSingletonStart() { this.BackgroundJobRunner.EnsureBackgroundThreadStarted(); + + NavMesh.pathfindingIterationsPerFrame = m_navMeshPathfindingIterationsPerFrame; } protected override void OnSingletonDisable()