using Mirror;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;
public class RTSMovement : NetworkBehaviour
{
[SerializeField] private NavMeshAgent agent = null;
private Camera mainCamera;
#region Server
[Command]
private void CmdMove(Vector3 position)
{
if (NavMesh.SamplePosition(position, out NavMeshHit hit, 1f, NavMesh.AllAreas)) { return; }
{
agent.SetDestination(hit.position);
}
}
#endregion
#region Client
public override void OnStartAuthority()
{
mainCamera = Camera.main;
}
[ClientCallback]
private void Update()
{
Debug.Log("A");
if(!isOwned) { return; }
if (!Input.GetMouseButton(1)) { return; }
Ray ray = mainCamera.ScreenPointToRay(Input.mousePosition);
if(!Physics.Raycast(ray, out RaycastHit hit, Mathf.Infinity)) { return; }
CmdMove(hit.point);
}
#endregion
}
I am pretty sure there are no issues in my code, but when I test this the debug is not called wish is logical because we are not using mono behavior and the method name does not become yellow. For some reason in the video the text does become yellow and I assume the method as a whole is called as well…