Нужна ваша помощь, я абсолютный ноль в программировании, но все же решил попробовать. В общем, задача проще некуда, включил урок на ютубе, дай думаю повторю, там парень писал скрипт для паука, чтобы он преследовал игрока и наносил урон, я писал код один в один, по итогу у него все работает и ошибок нет, а у меня одна критическая ошибка, из-за чего она вылезла непонятно, ссылается на 5 и 9 строчки кода (если я правильно понял). Вот текст ошибки: The type or namespace name 'NavMeshAgent' could not be found (are you missing a using directive or an assembly reference?) Вот сам код:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Zombie : MonoBehaviour
{
const float DAMAGE = 0.2f;
Animator animator;
NavMeshAgent agent;
GameObject player;
Player health;
float visible = 4f;
// Start is called before the first frame update
void Start()
{
animator = GetComponent<Animator>();
agent = GetComponent<NavMeshAgent>();
player = GameObject.FindGameObjectWithTag("Player");
if (player != null)
{
health = player.GetComponent<Player>();
}
}
// Update is called once per frame
void Update() {
if (player != null)
{
float distance = Vector3.Distance(transform.position, player.transform.position);
if (distance < 1f)
{
health.Damage(DAMAGE);
}
else if (distance < visible)
{
agent.destination = player.transform.position;
}
}
}
}
0xfffffeef