//---------------------------------------------------------------------------- // Zoom //---------------------------------------------------------------------------- #region Zoom /// <summary> /// Self Explanatory purpose <para /> /// Updates ZoomControlled based on input and clamps it <para /> /// Lerps ZoomLerped to ZoomControlled <para /> /// /// Keeps the camera the right offset from FocusLerped based on ZoomLerped <para /> /// </summary> public void UpdateZoomVariables() { ZoomControlled += MyBattleCamInput.ZoomInput() * ZoomSpeed * DefaultZoomSpeed; ZoomControlled = Mathf.Clamp(ZoomControlled, MinimumZoom, MaximumZoom); ZoomLerped = Mathf.Lerp(ZoomLerped, ZoomControlled, Time.deltaTime * ZoomLerpSpeed); }
//---------------------------------------------------------------------------- // Translate //---------------------------------------------------------------------------- #region Translate public void TranslateFocus() { float deltaX = MyBattleCamInput.TranslateRightInput(); float deltaZ = MyBattleCamInput.TranslateForwardInput(); //If zooming the opposite direction of travelling, increase travel speed so it stays roughly constant if (MyBattleCamInput.ZoomInput() * MyBattleCamInput.TranslateForwardInput() > 0) { deltaZ += MyBattleCamInput.ZoomInput() * DefaultZoomCorrection; } Vector3 deltaTranslate = new Vector3(0, 0, 0); deltaTranslate += deltaX * FocusControlled.right; deltaTranslate += deltaZ * FocusControlled.forward; deltaTranslate = deltaTranslate * Time.deltaTime * AltitudeSpeed * DefaultTranslationSpeed * TranslationSpeed; FocusControlled.position += deltaTranslate; }