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.
using UnityEngine;
using System.Collections;
public class test : MonoBehaviour {
private NavMeshAgent navMeshAgent;
void Start ()
{
navMeshAgent = GetComponent<NavMeshAgent>();
navMeshAgent.autoTraverseOffMeshLink = false;
//navMeshAgent.destination = Vector3.zero; used for npc's
}
// Update is called once per frame
void Update ()
{
navMeshAgent.Move(Vector3.forward * Time.deltaTime); //used for player
if (navMeshAgent.isOnOffMeshLink)
Debug.Log("OffMeshLink");
}
}
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.
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.
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.
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