Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Resolved NavMeshAgent not attached to GameObject

Discussion in 'Navigation' started by dasruedi_unity, Dec 2, 2022.

  1. dasruedi_unity

    dasruedi_unity

    Joined:
    Jul 20, 2022
    Posts:
    10
    Hello there,


    This is a followup Question to this thread I posted earlier today:
    https://forum.unity.com/threads/runtime-navmesh-baking.1368801/

    I was following this tutorial:


    And I wanted to get an NavMeshAgent that moves towards a target location.
    I copied this script from the tutorial video:
    upload_2022-12-2_17-0-46.png

    And while it worked for the tutorials creator, I get the Debug.LogError message that the NavMeshAgent is not attached to the gameobject.

    But it is there:
    upload_2022-12-2_17-2-42.png

    Since the script doesn't acknowledge the existence of the Agent it doesn't move. What is the issue here? is it because of the package I added to resolve my issue from the linked thread because the tutorial creator added that a few parts later? But it worked for them later on too...

    I hope you can help me and thanks in advance for all answers.
     
  2. dasruedi_unity

    dasruedi_unity

    Joined:
    Jul 20, 2022
    Posts:
    10
    I just realized that the issue is that I asked if the _navMeshAgent is unequal to null. I fixed it and it works now.