using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.AI; public class PlayerMovement : MonoBehaviour { public LayerMask whatCanBeClickedOn; private UnityEngine.AI.NavMeshAgent myAgent; // Start is called before the first frame update void Start() { myAgent = GetComponent (); } // Update is called once per frame void Update() { if (Input.GetMouseButtonDown(0)) { Ray myRay = Camera.main.ScreenPointToRay (Input.mousePosition); RaycastHit hitInfo; if(Physics.Raycast (myRay, out hitInfo, 100, whatCanBeClickedOn)) { myAgent.SetDestination (hitInfo.point); } } } }