Cute_demon_attacks/meng_yao/Assets/Scene/demo.cs
2024-12-09 11:56:41 +08:00

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);
}
}
}