24 lines
518 B
C#
24 lines
518 B
C#
using Mirror;
|
|
using UnityEngine;
|
|
using UnityEngine.AI;
|
|
using UnityEngine.InputSystem;
|
|
|
|
public class UnitMovement : NetworkBehaviour
|
|
{
|
|
[SerializeField] private NavMeshAgent _navMeshAgent;
|
|
|
|
private Camera _camera;
|
|
private Mouse _mouse;
|
|
|
|
#region Server
|
|
|
|
[Command] public void CmdMove(Vector3 destination)
|
|
{
|
|
if (NavMesh.SamplePosition(destination, out NavMeshHit hit, 1f, NavMesh.AllAreas))
|
|
{
|
|
_navMeshAgent.SetDestination(hit.position);
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
} |