Выводит слудеющая ошибка
"SetDestination" can only be called on an active agent that has been placed on a NavMesh.
вот код:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;
public class EnemyController : MonoBehaviour
{
public float lookRadius = 10f;
private Transform target;
private NavMeshAgent agent;
void Start()
{
agent = GetComponent<NavMeshAgent>();
target = PlayerManager.instance.player.transform;
}
void Update()
{
float distance = Vector3.Distance(target.position, transform.position);
if (distance <= lookRadius)
{
agent.destination = target.position;
}
}
void OnDrawGizmosSelected()
{
Gizmos.color = Color.red;
Gizmos.DrawWireSphere(transform.position, lookRadius);
}
}
еще есть предупреждение какое-то
Посикал в инете. надо установить navmeshagent с помощью
![image.png?width=234&height=24](https://habrastorage.org/extt/64/5c/4c/645c4c4e374ef349889753.png?width=234&height=24)
но ничего не получаеться. помогите . версия юнинти: 2021.3