Бот не хочет идти по точкам, я уже не знаю что делать все перерыл везде такой же метод используют как и я
вот код:
public class NextBots2 : MonoBehaviour
{
public NavMeshAgent navMeshAgent;
public Transform player;
public static int difficult = -1;
public Transform door;
public Transform[] points;
[SerializeField] private int currentPoint;
void Start()
{
currentPoint = -1;
navMeshAgent = GetComponent<NavMeshAgent>();
}
void Update()
{
CheckPlayerOnRoom();
if (currentPoint != -1)
{
navMeshAgent.SetDestination(points[currentPoint].position);
}
if (navMeshAgent.remainingDistance < 0.5f)
{
currentPoint++;
}
if (currentPoint >= points.Length)
{
currentPoint = 0;
}
print(currentPoint);
difficult = Settings.diff;
if (difficult == 0) navMeshAgent.speed = 5f;
else if (difficult == 1) navMeshAgent.speed = 7f;
else if (difficult == 2) navMeshAgent.speed = 9f;
else if (difficult == 3) navMeshAgent.speed = 11f;
}
void CheckPlayerOnRoom()
{
if (Check.playerOnRoom && door.transform.rotation == Quaternion.Euler(0, -90, 0))
{
if (currentPoint == -1) currentPoint = 0;
}
else
{
currentPoint = -1;
navMeshAgent.SetDestination(player.transform.position);
}
}
}