using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.AI;
public class Player : MonoBehaviour { NavMeshAgent agent;
// Start is called before the first frame update void Start() { agent = GetComponent<NavMeshAgent>(); }
// Update is called once per frame void Update() { 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); } } } }