- Home /
Question by
snowy6409 · Jun 14, 2016 at 11:32 PM ·
scripting problemnetworkingnavigation
I need help with unity navigation networking
Hello guys I need help with a C# script that is the Goto Mouse script for navigation but I can not get it working in Multiplayer. Please help.
using UnityEngine;
using UnityEngine.Networking;
public class Movetopoint : NetworkBehaviour
{
NavMeshAgent agent;
public GameObject cam;
void Start()
{
agent = GetComponent<NavMeshAgent>();
}
void Update()
{
if (!isLocalPlayer)
{
return;
}
if (Input.GetMouseButtonDown(0))
{
RaycastHit hit;
if (Physics.Raycast(Camera.current.ScreenPointToRay(Input.mousePosition), out hit, 100))
{
Debug.Log("Hit");
agent.destination = hit.point;
}
}
}
}
Comment
Answer by HarshadK · Jun 15, 2016 at 06:02 AM
You need to add NetworkIdentity and NetworkTransform components on the gameobject to network its position.