Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

How to use standard asset "AIThirdPersonController"?

Discussion in 'Navigation' started by bboydaisuke, May 9, 2015.

  1. bboydaisuke

    bboydaisuke

    Joined:
    Jun 14, 2014
    Posts:
    67
    Hello,

    I'd like to use standard asset "AIThirdPersonController" with Unity 5 but fails with a warning "Failed to create agent because there is no valid NavMesh".
    This is what I have failed so far:

    1. create new scene
    2. put plane
    3. put AIThirdPersonController
    4. put cube
    5. set Target to cube in AI Character Control of AIThirdPersonController
    6. play

    then I saw these two warning and error.
    Warning: Failed to create agent because there is no valid NavMesh
    Error: "SetDestination" can only be called on an active agent that has been placed on a NavMesh.
    Obviously the error is caused by the warning.

    What I need to make it work? I also checked Unity 5's sample project. It has a sample scene named "CharacterThirdPersonAI" which utilizes the asset. I noticed the project has subfolder named same as the scene and the folder has "NavMesh" asset. I deleted it from project then it throws same warning as mine.
    However, I can't find how the scene uses the NavMesh thing.

    thanks,
    bboydaisuke
     
  2. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
  3. bboydaisuke

    bboydaisuke

    Joined:
    Jun 14, 2014
    Posts:
    67
    PanderaStudios likes this.
  4. zviaz

    zviaz

    Joined:
    Mar 27, 2015
    Posts:
    29
    Just to give you another tip when creating your own custom AI scripts you will need to attach a Nav Mesh Agent to the AI you want to be able to move around your navigation mesh.

    Also, BEFORE you bake your navmesh you should ensure all static assets are marked as "static" (especially the floor/ground) in the inspector window otherwise you can get some weird collision errors for both AI and players.

    Also note-worthy is to check for the navmesh component in the script if you intend to do more complex tasks such as waypoints.

    [RequireComponent (typeof(NavMeshAgent))]

    public class RandomScript : MonoBehaviour {

    The rest of your code

    }