Mirror Multiplayer and Nav

Hello everyone! I’m pretty new so I am gonna try to break this down the best I can.
I followed Mirror’s quick start guide for multiplayer and it works great. The problem I am having is with the playerscript, where I am using baked in navigation on the floor and a nav mesh agent on the player.

When I play the game and start the server as host, I can click around and move fine. When I open up another instance of Unity and connect as the client I get the “Failed to create agent because there is no valid NavMesh” warning and then when I click to move I get the ““SetDestination” can only be called on an active agent that has been placed on a NavMesh” error.

Here is my playerscript.cs:

using System.Collections;
using System.Collections.Generic;
using Mirror;
using UnityEngine;
using UnityEngine.AI;

namespace QuickStart
{
    public class PlayerScript : NetworkBehaviour
    {

        NavMeshAgent agent;

        void Start()
        {
            agent = GetComponent<NavMeshAgent> ();
        }

        void Update()
        {
            if (!isLocalPlayer) { return; }

            if(Input.GetMouseButtonDown(0))
            {
                RaycastHit hit;
                Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
                if(Physics.Raycast(ray, out hit, Mathf.Infinity));
                {
                    agent.SetDestination(hit.point);
                }
            }
        }
    }
}
1 Like

I have the same problem with Unity Netcode it works fine on the host but it does not work on the client side.