1

Нужна ваша помощь, я абсолютный ноль в программировании, но все же решил попробовать. В общем, задача проще некуда, включил урок на ютубе, дай думаю повторю, там парень писал скрипт для паука, чтобы он преследовал игрока и наносил урон, я писал код один в один, по итогу у него все работает и ошибок нет, а у меня одна критическая ошибка, из-за чего она вылезла непонятно, ссылается на 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;
            }
        }
        
    }
}
3
  • "я абсолютный ноль в программировании" - Вы меня развеселили. +1 Вам за это.
    – user176262
    20 дек 2020 в 17:11
  • абсолютный ноль - это 0xfffffeef
    – aepot
    20 дек 2020 в 17:17
  • 1
    @aepot а если по Кельвину?
    – Bulson
    20 дек 2020 в 17:20

1 ответ 1

1
...
using UnityEngine;
using UnityEngine.AI;

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.