private async Task <bool> MovingToGate() { if (TargetGatePosition == Vector3.Zero) { Core.Logger.Debug("Can't move to unspecified TargetGatePosition"); State = States.Failed; return(false); } var distance = TargetGatePosition.Distance(AdvDia.MyPosition); if (distance > 5f) { Core.Logger.Debug($"Moving to TargetGatePosition: {TargetGatePosition} in {TargetGateScene.Name} Distance={distance}"); if (_navigationCoroutine == null || _navigationCoroutine.Destination != TargetGatePosition) { _navigationCoroutine = new NavigationCoroutine(TargetGatePosition, 4); } if (!await _navigationCoroutine.GetCoroutine()) { return(false); } distance = TargetGatePosition.Distance(AdvDia.MyPosition); if (distance > 8f) { //if (NavigationCoroutine.LastResult == CoroutineResult.Failure) //{ _moveAttempts++; if (_moveAttempts < _maxFailedMoveToGateAttempts) { Core.Logger.Debug($"Failed attempt #{_moveAttempts} moving to {TargetGatePosition} Distance={distance}."); _navigationCoroutine = null; return(false); } Core.Logger.Debug($"Failed to move to TargetGatePosition, Max Attempts Reached ({_maxFailedMoveToGateAttempts}), finished."); State = States.Failed; //} //Core.Logger.Debug($"Failed to move to TargetGatePosition, too far away from gate ({distance}). finished."); //State = States.Failed; return(false); } } Core.Logger.Debug($"Successfully moved to gate {TargetGatePosition} within {TargetGateScene.Name}."); CurrentGateScene = DeathGates.CurrentGateScene; if (CurrentGateScene == null) { Core.Logger.Debug("Unable to find a gate scene"); State = States.Failed; return(false); } Core.Logger.Debug($"Updated current scene to {CurrentGateScene.Name}"); State = States.Interacting; _moveAttempts = 0; return(false); }