xirang/Assets/scripts/enemy.cs

34 lines
666 B
C#
Raw Normal View History

2024-11-26 22:01:14 +08:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;
public class enemy : MonoBehaviour
{
public NavMeshAgent _agent;
public float bloodvolume;
public Transform player;
// Start is called before the first frame update
void Start()
{
_agent = GetComponent<NavMeshAgent>();
player=GameObject.FindWithTag("Player").transform;
}
// Update is called once per frame
void Update()
{
setMoveTo(player);
}
public void setMoveTo(Transform target)
{
_agent.SetDestination(target.position);
}
}