So i have a script for an enemy that follows a player:
using UnityEngine;
using UnityEngine.AI;
[DisallowMultipleComponent]
[RequireComponent(typeof(NavMeshAgent))]
public class MazeEnemy : MonoBehaviour
{
// Private Variables
private Transform player;
private NavMeshAgent agent;
private void Start()
{
player = FindFirstObjectByType<Player>().transform;
agent = GetComponent<NavMeshAgent>();
}
private void FixedUpdate()
{
agent.SetDestination(player.position);
}
}
but i need him not to be able to turn around and go backwards, but instead find a way round