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

NavMeshAgent.Warp() not working

Discussion in 'Navigation' started by ics_de, Feb 6, 2019.

  1. ics_de

    ics_de

    Joined:
    Dec 6, 2017
    Posts:
    27
    So this is my code for spawning an AI car. I am using Warp() to avoid the "not detecting navmesh" error. However, when it spawns I get the error "SetDestination can only be called on an active agent that has been placed on a NavMesh". As you may see, I've tried to place it, but it doesen't seem to work. Any idea?

    upload_2019-2-6_18-16-49.png
     
  2. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,294
    You could just spawn it at hit.position, as that's on the navmesh. Then you don't have to warp it.
     
  3. ics_de

    ics_de

    Joined:
    Dec 6, 2017
    Posts:
    27
    I've tried out, but I keep getting the same error :/
     
  4. ics_de

    ics_de

    Joined:
    Dec 6, 2017
    Posts:
    27
    Also, I've tried a lot of suggestions of other threads similar to this one :/
     
  5. abuklea

    abuklea

    Joined:
    Mar 2, 2013
    Posts:
    13
    Hi @Uri677 .. same issue here. Did you find a solution?
     
  6. ics_de

    ics_de

    Joined:
    Dec 6, 2017
    Posts:
    27
    Nope, just left aside the project :(
     
  7. ics_de

    ics_de

    Joined:
    Dec 6, 2017
    Posts:
    27
    Hey, so I've been progressing in ohter projects and found out that this doesn't happen if your game / NavMeshAgents aren't too small!
     
    eterlan likes this.
  8. Shiiv

    Shiiv

    Joined:
    Jul 29, 2020
    Posts:
    10
    Wow thanks a lot for this information !
    I just spent like 4 hours on a bug in my project, monsters randomly not spawning where they should -.-
    In the end i used NavMeshAgent.warp instead of directly modifying the transform.position.
    And before using the warp, i modify the agent radius to a bigger one (0.5f in my case), and then switch it back to the actual value after the successful warp :eek:
    Don't know why there is so little information about this "bug" (i guess it is), i did not find anything though you saved what ever is left of my night :,D
    Thanks again :)
     
  9. ics_de

    ics_de

    Joined:
    Dec 6, 2017
    Posts:
    27
    You're welcome! I actually stumble upon this problem every single time I use navmeshes, so save a link to this thread or smth for future use! :)

    I hope Unity work on it cuz it's really unintuitive to solve, tbh.
     
  10. charanchaganti

    charanchaganti

    Joined:
    Mar 16, 2022
    Posts:
    13
    I also changed the radius to 0.5f but I am getting the same error

    I have been stuck on this issue since 4 dyas while I was doi g other things plz suggest