26 lines
508 B
C#
26 lines
508 B
C#
using UnityEngine;
|
|
using System.Collections;
|
|
using UnityEngine.AI;
|
|
|
|
public class demo : MonoBehaviour {
|
|
|
|
private NavMeshAgent agent;
|
|
void Start()
|
|
{
|
|
agent = GetComponent<NavMeshAgent>();
|
|
}
|
|
|
|
void Update()
|
|
{
|
|
RaycastHit hit;
|
|
if (Input.GetMouseButtonDown(0))
|
|
{
|
|
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
|
|
if (Physics.Raycast(ray, out hit))
|
|
agent.SetDestination(hit.point);
|
|
}
|
|
}
|
|
|
|
|
|
}
|