Added destination validation for move command

This commit is contained in:
Stedd 2023-09-03 15:14:01 +02:00
parent edc946e6ef
commit b1bd6379ed
1 changed files with 4 additions and 1 deletions

View File

@ -14,7 +14,10 @@ public class PlayerMovement : NetworkBehaviour
[Command] private void CmdMove(Vector3 destination)
{
_navMeshAgent.SetDestination(destination);
if (NavMesh.SamplePosition(destination, out NavMeshHit hit, 1f, NavMesh.AllAreas))
{
_navMeshAgent.SetDestination(hit.position);
}
}
#endregion