public bool MoveOverOffmeshConnection(NavPolyId offMeshConRef, NavPolyId[] refs, ref Vector3 startPos, ref Vector3 endPos, NavMeshQuery navquery) { //advance the path up to and over the off-mesh connection NavPolyId prevRef = NavPolyId.Null, polyRef = path[0]; int npos = 0; while (npos < path.Count && polyRef != offMeshConRef) { prevRef = polyRef; polyRef = path[npos]; npos++; } if (npos == path.Count) { //could not find offMeshConRef return(false); } //prune path path.RemoveRange(0, npos); refs[0] = prevRef; refs[1] = polyRef; TiledNavMesh nav = navquery.NavMesh; if (nav.GetOffMeshConnectionPolyEndPoints(refs[0], refs[1], ref startPos, ref endPos) == true) { pos = endPos; return(true); } return(false); }
public bool MoveOverOffmeshConnection(int offMeshConRef, int[] refs, ref Vector3 startPos, ref Vector3 endPos, NavMeshQuery navquery) { //advance the path up to and over the off-mesh connection int prevRef = 0, polyRef = path[0]; int npos = 0; while (npos < pathCount && polyRef != offMeshConRef) { prevRef = polyRef; polyRef = path[npos]; npos++; } if (npos == pathCount) { //could not find offMeshConRef return(false); } //prune path for (int i = npos; i < pathCount; i++) { path[i - npos] = path[i]; } pathCount -= npos; refs[0] = prevRef; refs[1] = polyRef; TiledNavMesh nav = navquery.NavMesh; if (nav.GetOffMeshConnectionPolyEndPoints(refs[0], refs[1], ref startPos, ref endPos) == true) { pos = endPos; return(true); } return(false); }