报错Assets\Scenes\GuaiWu.cs(23,9): error CS0103: The name 'Wol' does not exist in the current context
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GuaiWu : MonoBehaviour
{
public enum EnemyState
{
idle,
run,
attack,
death,
}
public EnemyState CurrentState = EnemyState.idle;
Animator imator;
UnityEngine.AI.NavMeshAgent agent;
// Start is called before the first frame update
void Start()
{
imator = GetComponent<Animator>();
agent = GetComponent<UnityEngine.AI.NavMeshAgent>();
Wol = GameObject.FindWithTag("Wolf").transform;
}
// Update is called once per frame
void Update()
{
float distance = Vector3.Distance(Wol.position, transform.position);
switch (CurrentState)
{
case EnemyState.idle:
if (distance > 2 && distance <= 10)
{
CurrentState = EnemyState.run;
}
if (distance < 2)
{
CurrentState = EnemyState.attack;
}
imator.Play("Idle");
agent.isStopped = true;
break;
case EnemyState.run:
if (distance > 10)
{
CurrentState = EnemyState.idle;
}
if (distance < 2)
{
CurrentState = EnemyState.attack;
}
imator.Play("Run");
agent.isStopped = false;
agent.SetDestination(Wol.position);
break;
}
}
}