NavMeshAgent in unity not working

12,395
  • Go to Window -> Navigation.
  • Click on the Bake tab.
  • Click on Bake in the bottom right corner.

This will bake the NavMesh and your NavMeshAgent will now work. Right now you have no NavMesh, so your Agents don't know where they can move/walk.

Share:
12,395
Marcus Mardis
Author by

Marcus Mardis

Updated on June 09, 2022

Comments

  • Marcus Mardis
    Marcus Mardis almost 2 years

    I am making a game in unity and it is throwing the error "Failed to create agent because there is no valid NavMesh" and i don't know what the problem is.

    Setup Pic

    using UnityEngine;
    using System.Collections;
    
    public class EnemyMotion : MonoBehaviour {
        public NavMeshAgent agent;
        public Rigidbody rb;
        public GameObject otwt;
    
        void Start () {
            rb = GetComponent<Rigidbody>();
            agent = GetComponent<NavMeshAgent>();
        }
        void Update () {
            gameObject.transform.Rotate(270, 0, 0);
            agent.SetDestination(otwt.transform.position);
        }
    }