I tried everything, i baked navigation mesh manually but still it doesn't work. If you know how to solve that problem please help me.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;
public class EnemyController : MonoBehaviour {
public float lookRadius = 10f;
Transform target;
public NavMeshAgent agent;
void Start () {
target = PlayerManager.instance.player.transform;
agent = GetComponent<NavMeshAgent> ();
if (agent.isOnNavMesh == false)
Debug.Log ("NOOOOOO");
}
void Update () {
float distance = Vector3.Distance (target.position, transform.position);
if (distance <= lookRadius){
agent.SetDestination (target.position);
}
}
void OnDrawGizmosSelected() {
Gizmos.color = Color.red;
Gizmos.DrawWireSphere(transform.position, lookRadius);
}
}