From bae1f0694ecb5d4e122f52f9bbea3faf891b94da Mon Sep 17 00:00:00 2001 From: in0finite Date: Mon, 14 Mar 2022 08:40:32 +0100 Subject: [PATCH] increase navmesh PathfindingIterationsPerFrame to 1000 --- Assets/Prefabs/GameManager.prefab | 1 + Assets/Scripts/Behaviours/PathfindingManager.cs | 5 +++++ 2 files changed, 6 insertions(+) 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()