Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only. On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live. Read our full announcement for more information and let us know if you have any questions.
    Dismiss Notice
  2. Dismiss Notice

NavMeshAgent teleports

Discussion in 'Navigation' started by Aseliot, Apr 10, 2020.

  1. Aseliot

    Aseliot

    Joined:
    May 7, 2019
    Posts:
    35
    Hi,

    I've used the NavMeshAgent before in another project and I wanted to use it again but now it just teleports somewhere else when I tell it move, it just does this a single time and then never moves.

    I have checked against my other working project and I see no differences in how I set it up?
    Anyone have any ideas?
     
  2. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    I'm seeing this same issue. Adding lots of extra move destinations in between seems to fix it, but there should be no reason why it can't calculate a valid path from anywhere on the terrain. I also have never seen this before. I'm using Unity 2019.3.8f1. How about you?
     
  3. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    I actually found another way to fix. I had my agent radius set to .35 and when I went back to the default of .5 the issue went away. So, this has something to do with smaller agent sizes. Still trying to figure out how to get smaller agent radius and not have teleporting.
     
  4. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    I spoke too soon. Even at .5 is still sometimes teleports. There seems to be no way to fix it except adding more waypoints. This is definitely a Unity bug, but doing a google search reveals that it's been around since many, many versions ago so I doubt it will be fixed.
     
  5. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    For me, it turns out this may not be NaveMeshAgent related. When I create a simple navigation script to set NavMeshAgent destination, it works fine, but when I use EmeraldAI's SetDestination, it is failing. So, might be an EmeraldAI issue for me.
     
  6. Aseliot

    Aseliot

    Joined:
    May 7, 2019
    Posts:
    35
    In my case I think I was calling the wrong function instead of SetDestination
     
  7. MidniteOil

    MidniteOil

    Joined:
    Sep 25, 2019
    Posts:
    344
    I am seeing the same issue. I'm using Unity 2021.3.13f1. The enemy is teleporting over 50 units from its spawning position (not directly to the destination).
     
  8. MidniteOil

    MidniteOil

    Joined:
    Sep 25, 2019
    Posts:
    344
    BTW, I thought it might be an issue that I'm instantiating the enemies from a pool, moving them to their spawn position and then setting their navmeshagent's destination. I thought maybe it was an issue with the navmeshagent being active while moving them to their spawn location so I disabled the navmeshagent in OnEnable and then re-enabled it just before setting the destination. Now they don't teleport but they don't move either :(
     
  9. jino00

    jino00

    Joined:
    May 18, 2022
    Posts:
    1
    "I had the same problem. I solved it by turning off the NavMeshAgent using 'GetComponent<NavMeshAgent>().enabled = false' when activating an object from the pool, and then turning it back on after nav.SetDestination."