public void UpdateCameraSnap() { if (KickStarter.mainCamera) { Camera targetCamera = GetComponent <Camera>(); KickStarter.mainCamera.transform.position = transform.position; KickStarter.mainCamera.transform.rotation = transform.rotation; KickStarter.mainCamera.Camera.orthographic = targetCamera.orthographic; KickStarter.mainCamera.Camera.fieldOfView = targetCamera.fieldOfView; KickStarter.mainCamera.Camera.farClipPlane = targetCamera.farClipPlane; KickStarter.mainCamera.Camera.nearClipPlane = targetCamera.nearClipPlane; KickStarter.mainCamera.Camera.orthographicSize = targetCamera.orthographicSize; #if ALLOW_PHYSICAL_CAMERA KickStarter.mainCamera.Camera.ResetProjectionMatrix(); KickStarter.mainCamera.Camera.usePhysicalProperties = targetCamera.usePhysicalProperties; if (targetCamera.usePhysicalProperties) { KickStarter.mainCamera.Camera.sensorSize = targetCamera.sensorSize; KickStarter.mainCamera.Camera.lensShift = targetCamera.lensShift; } #endif if (MainCamera.AllowProjectionShifting(targetCamera)) { Camera.main.projectionMatrix = AdvGame.SetVanishingPoint(Camera.main, perspectiveOffset, true); } } }
private void SetProjection() { if (MainCamera.AllowProjectionShifting(Camera)) { Camera.projectionMatrix = AdvGame.SetVanishingPoint(Camera, perspectiveOffset); } }
private void SetProjection() { if (!_camera.orthographic) { _camera.projectionMatrix = AdvGame.SetVanishingPoint(_camera, perspectiveOffset); } }
public void ResetProjection() { if (_camera) { perspectiveOffset = Vector2.zero; _camera.projectionMatrix = AdvGame.SetVanishingPoint(_camera, perspectiveOffset); _camera.ResetProjectionMatrix(); } }
private void SetProjection() { if (!_camera.orthographic) { _camera.projectionMatrix = AdvGame.SetVanishingPoint(_camera, perspectiveOffset); } else { transform.position = new Vector3(originalPosition.x + perspectiveOffset.x, originalPosition.y + perspectiveOffset.y, transform.position.z); } }
protected void SetProjection() { if (!Camera.orthographic && _is2D) { Camera.projectionMatrix = AdvGame.SetVanishingPoint(Camera, perspectiveOffset); } else { transform.position = new Vector3(originalPosition.x + perspectiveOffset.x, originalPosition.y + perspectiveOffset.y, originalPosition.z); } }
private void SetProjection() { Vector2 snapOffset = GetSnapOffset(); if (_camera.orthographic) { transform.position = originalPosition + (transform.right * snapOffset.x) + (transform.up * snapOffset.y); } else { _camera.projectionMatrix = AdvGame.SetVanishingPoint(_camera, snapOffset); } }
private void UpdateCameraSnap (GameCamera25D _target) { if (KickStarter.mainCamera) { KickStarter.mainCamera.transform.position = _target.transform.position; KickStarter.mainCamera.transform.rotation = _target.transform.rotation; Camera.main.orthographic = _target.GetComponent <Camera>().orthographic; Camera.main.fieldOfView = _target.GetComponent <Camera>().fieldOfView; Camera.main.farClipPlane = _target.GetComponent <Camera>().farClipPlane; Camera.main.nearClipPlane = _target.GetComponent <Camera>().nearClipPlane; Camera.main.orthographicSize = _target.GetComponent <Camera>().orthographicSize; if (!Camera.main.orthographic) { Camera.main.projectionMatrix = AdvGame.SetVanishingPoint (Camera.main, _target.perspectiveOffset); } } }
public void _LateUpdate() { if (KickStarter.settingsManager && KickStarter.settingsManager.IsInLoadingScene()) { return; } if (KickStarter.stateHandler.gameState == GameState.Normal) { if (attachedCamera) { if (lastNavCamera != attachedCamera) { lastNavCamera2 = lastNavCamera; } lastNavCamera = attachedCamera; } } if (attachedCamera && (!(attachedCamera is GameCamera25D))) { if (!isSmoothChanging) { transform.rotation = attachedCamera.transform.rotation; transform.position = attachedCamera.transform.position; focalDistance = attachedCamera.focalDistance; if (attachedCamera is GameCamera2D) { GameCamera2D cam2D = (GameCamera2D)attachedCamera; perspectiveOffset = cam2D.perspectiveOffset; if (!_camera.orthographic) { _camera.projectionMatrix = AdvGame.SetVanishingPoint(_camera, perspectiveOffset); } else { _camera.orthographicSize = attachedCamera._camera.orthographicSize; } } else { _camera.fieldOfView = attachedCamera._camera.fieldOfView; if (cursorAffectsRotation) { SetlookAtTransformation(); transform.LookAt(lookAtTransform, attachedCamera.transform.up); } } } else { // Move from one GameCamera to another if (Time.time < startTime + changeTime) { if (attachedCamera is GameCamera2D) { GameCamera2D cam2D = (GameCamera2D)attachedCamera; perspectiveOffset.x = AdvGame.Lerp(startPerspectiveOffset.x, cam2D.perspectiveOffset.x, AdvGame.Interpolate(startTime, changeTime, moveMethod, timeCurve)); perspectiveOffset.y = AdvGame.Lerp(startPerspectiveOffset.y, cam2D.perspectiveOffset.y, AdvGame.Interpolate(startTime, changeTime, moveMethod, timeCurve)); _camera.ResetProjectionMatrix(); } if (moveMethod == MoveMethod.Curved) { // Don't slerp y position as this will create a "bump" effect Vector3 newPosition = Vector3.Slerp(startPosition, attachedCamera.transform.position, AdvGame.Interpolate(startTime, changeTime, moveMethod, timeCurve)); newPosition.y = Mathf.Lerp(startPosition.y, attachedCamera.transform.position.y, AdvGame.Interpolate(startTime, changeTime, moveMethod, timeCurve)); transform.position = newPosition; transform.rotation = Quaternion.Slerp(startRotation, attachedCamera.transform.rotation, AdvGame.Interpolate(startTime, changeTime, moveMethod, timeCurve)); } else { transform.position = AdvGame.Lerp(startPosition, attachedCamera.transform.position, AdvGame.Interpolate(startTime, changeTime, moveMethod, timeCurve)); transform.rotation = AdvGame.Lerp(startRotation, attachedCamera.transform.rotation, AdvGame.Interpolate(startTime, changeTime, moveMethod, timeCurve)); } focalDistance = AdvGame.Lerp(startFocalDistance, attachedCamera.focalDistance, AdvGame.Interpolate(startTime, changeTime, moveMethod, timeCurve)); _camera.fieldOfView = AdvGame.Lerp(startFOV, attachedCamera._camera.fieldOfView, AdvGame.Interpolate(startTime, changeTime, moveMethod, timeCurve)); _camera.orthographicSize = AdvGame.Lerp(startOrtho, attachedCamera._camera.orthographicSize, AdvGame.Interpolate(startTime, changeTime, moveMethod, timeCurve)); if (attachedCamera is GameCamera2D && !_camera.orthographic) { _camera.projectionMatrix = AdvGame.SetVanishingPoint(_camera, perspectiveOffset); } } else { LookAtCentre(); isSmoothChanging = false; } } if (cursorAffectsRotation) { lookAtTransform.localPosition = Vector3.Lerp(lookAtTransform.localPosition, lookAtTarget, Time.deltaTime * 3f); } } else if (attachedCamera && (attachedCamera is GameCamera25D)) { transform.position = attachedCamera.transform.position; transform.rotation = attachedCamera.transform.rotation; } // Shake if (shakeIntensity > 0f) { if (shakeMove) { shakePosition = Random.insideUnitSphere * shakeIntensity * 0.5f; } shakeRotation = new Vector3 ( Random.Range(-shakeIntensity, shakeIntensity) * 0.2f, Random.Range(-shakeIntensity, shakeIntensity) * 0.2f, Random.Range(-shakeIntensity, shakeIntensity) * 0.2f ); shakeIntensity = Mathf.Lerp(shakeStartIntensity, 0f, AdvGame.Interpolate(shakeStartTime, shakeDuration, MoveMethod.Linear, null)); transform.position += shakePosition; transform.localEulerAngles += shakeRotation; } else if (shakeIntensity < 0f) { StopShaking(); } }