Search Unity

[NavMeshAgent] isOnOffMeshLink + Move()

Discussion in 'Scripting' started by MaxRoetzler, Dec 22, 2012.

  1. MaxRoetzler

    MaxRoetzler

    Joined:
    Jan 3, 2010
    Posts:
    136
    Hello,

    I'm currently trying to make use of the NavMesh - OffMeshLinks. For NPC controlled characters (using NavMeshAgent.SetDestination) everything is working fine. However for the player controlled character (using NavMeshAgent.Move), the isOnOffMeshLink doesn't report anything. I tested it with manual and auto generated links. I was hoping player controlled agents could automatically make use of the links as well.

    Here's some pseudo test code for the scenario in case I'm missing something. The player character does walk right into the link area in my scene.
    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4.  
    5. public class test : MonoBehaviour {
    6.     private NavMeshAgent navMeshAgent;
    7.  
    8.     void Start ()
    9.     {
    10.         navMeshAgent = GetComponent<NavMeshAgent>();
    11.         navMeshAgent.autoTraverseOffMeshLink = false;
    12.         //navMeshAgent.destination = Vector3.zero; used for npc's
    13.     }
    14.    
    15.     // Update is called once per frame
    16.     void Update ()
    17.     {
    18.         navMeshAgent.Move(Vector3.forward * Time.deltaTime); //used for player
    19.  
    20.         if (navMeshAgent.isOnOffMeshLink)
    21.             Debug.Log("OffMeshLink");
    22.     }
    23. }
    24.  
    Thanks in advance
     
    Last edited: Jul 23, 2018
  2. GuoRay

    GuoRay

    Joined:
    Mar 1, 2014
    Posts:
    1
    Hi, I met the same problem, did you solve it ?
     
  3. MaxRoetzler

    MaxRoetzler

    Joined:
    Jan 3, 2010
    Posts:
    136
    Nope... the agent doesn't seem to report this while its player controlled. I didn't pursue it any further, but I think its best to rely on manually generated off-mesh links and add triggers to register the player character, so you can still use the in out points.
     
  4. NTDC-DEV

    NTDC-DEV

    Joined:
    Jul 22, 2010
    Posts:
    593
    Same problem.

    NavMeshAgent.isOnOffMeshLink always returns false.
     
  5. Eclectus

    Eclectus

    Joined:
    Oct 29, 2012
    Posts:
    20
    Any more information on this? I am seeing the same behaviour, NavMeshAgent.isOnOffMeshLink always returns false.
     
  6. Robosaru

    Robosaru

    Joined:
    Mar 31, 2013
    Posts:
    9
    This still seems to be broken - did anyone manage to solve?
     
  7. Psyco92

    Psyco92

    Joined:
    Nov 15, 2013
    Posts:
    22
    dearamy likes this.
  8. niflying

    niflying

    Joined:
    Jul 11, 2012
    Posts:
    108
  9. laessnb

    laessnb

    Joined:
    Jun 10, 2014
    Posts:
    101
    This still seemingly has issues. Haven't tried in 2018.1 but I didn't see any relevant fixes mentioned. What I've found is that it works only if the NavMeshAgent has a collider on it, and only if using pathfinding (versus .Move() or .velocity). That's too heavyweight for what I need, since I don't want to recalculate a new path every update for small movements of my player character. Any thoughts would be welcome.
     
  10. Ermiq

    Ermiq

    Joined:
    May 1, 2018
    Posts:
    11
    Unity 2018.1.3f1. Still doesn't work with player controlled character.
     
  11. rogersteve97

    rogersteve97

    Joined:
    Apr 26, 2017
    Posts:
    1
    Still does not work in Unity 2018.3.0f1, I'm not sure why they haven't fixed this yet.
     
  12. HAIRGROW

    HAIRGROW

    Joined:
    May 17, 2013
    Posts:
    19
    Unfortunately this is still a problem. I'm currently building a VR game where the player controls their movement via a NavMesh Agent. The "Player Agent" is moved by calculating a propulsion value and then feeding this into navMeshAgent.Move(actualPropulsion). The system works very well for movement and I get the added benefit of "Walls" because the "Player Agent" can't move beyond the NavMesh. But now I want the Player to jump off ledges/platforms. The Player can not do so, because they're now grounded to the NavMesh. I hoped using OffMesh links, would solve this problem, but have discovered that OffMesh Links only work if you're using SetDestination(). I hoping someone has discovered a way to use OffMesh Links when using .Move() on the NavMesh Agent.
     
    qzpobo likes this.
  13. maguslin

    maguslin

    Joined:
    Mar 9, 2015
    Posts:
    9
    you dont need to do that, because you've controller the player all the time ,what you need is just close the agent by navmeshagent.enable=false,and then set transform.position directly. after teleport finished just set agent.enable = true