mirror of
https://github.com/GTA-ASM/SanAndreasUnity
synced 2024-11-10 06:34:16 +00:00
sample position before warping agent, to prevent Unity to spam with warnings
This commit is contained in:
parent
a250cbd42e
commit
2ae03ccf9b
1 changed files with 6 additions and 1 deletions
|
@ -21,6 +21,8 @@ namespace SanAndreasUnity.Utilities
|
|||
private float m_lastTimeWhenWarped = 0f;
|
||||
private float m_timeWhenSampledOffNavMesh = 0f;
|
||||
|
||||
public float warpSampleDistance = 4.5f;
|
||||
|
||||
public Vector3 DesiredDirection
|
||||
{
|
||||
get
|
||||
|
@ -138,7 +140,10 @@ namespace SanAndreasUnity.Utilities
|
|||
bool bWarp = false;
|
||||
bool bSetDestination = false;
|
||||
|
||||
if (agent.Warp(myPosition))
|
||||
// here we sample position to prevent Unity to spam with warning messages saying that agent is
|
||||
// not close to nav mesh
|
||||
if (NavMesh.SamplePosition(myPosition, out var hit, this.warpSampleDistance, agent.areaMask)
|
||||
&& agent.Warp(myPosition))
|
||||
{
|
||||
bWarp = true;
|
||||
if (this.Destination.HasValue && agent.isOnNavMesh)
|
||||
|
|
Loading…
Reference in a new issue