/// <summary> /// Drive locomotion to walk towards point. /// Returns: /// 1 - arrived at location. /// 0 - walking(pathing) to location. /// -1 - can't reach location. /// </summary> public int WalkTo(Vector2 Location, int OccupiedId = 0) { StandUp(); // Destination position can be shifted, but can only be shifted by 0.25 max. Therefore a successful walk // is 0.3 from destination. if ((mPosition - Location).sqrMagnitude <= (0.3f * 0.3f)) { CancelWalking(); return(1); } if (_pathCounter >= 20) { _pathCounter = 0; //mNavPath = CPathFinder.FindPathSmoothed(mOwner, mWorld.mMap, mPosition, mPathDest); // TODO: Make sure owner is a valid player? System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch(); sw.Start(); mNRNavPath = CNavRectPather.FindPath(mWorld.mMap.mNavMeshes[mOwner], mPosition, Location, OccupiedId); sw.Stop(); //Debug.LogWarning("Path: " + sw.Elapsed.TotalMilliseconds + "ms"); if (mNRNavPath != null) { // Eliminate first node because we are already standing on it //mNRNavPath = mNRNavPath.mNextMove; mPathing = true; } else { mPathing = false; mPathDest = Vector2.zero; } } return(0); }