Added destination validation for move command
This commit is contained in:
parent
edc946e6ef
commit
b1bd6379ed
|
@ -14,7 +14,10 @@ public class PlayerMovement : NetworkBehaviour
|
||||||
|
|
||||||
[Command] private void CmdMove(Vector3 destination)
|
[Command] private void CmdMove(Vector3 destination)
|
||||||
{
|
{
|
||||||
_navMeshAgent.SetDestination(destination);
|
if (NavMesh.SamplePosition(destination, out NavMeshHit hit, 1f, NavMesh.AllAreas))
|
||||||
|
{
|
||||||
|
_navMeshAgent.SetDestination(hit.position);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
Loading…
Reference in New Issue