private void Start() { if (!isLocalPlayer) { Destroy(this); return; } InitCameraParameters(); originalParameters = StoreCameraParameters(); playerLayer = LayerMask.NameToLayer("Player"); mainCamera = Camera.main.transform; mouseForward = transform.forward; mouseOffset = cameraOffset; var origin = transform.position + targetHeight * Vector3.up; mainCamera.position = origin + cameraOffset; mainCamera.LookAt(origin + focalDistance * mouseForward); m_CameraTargetRot = Quaternion.Euler(0f, 0f, 0f); originalCameraDistance = cameraOffset.magnitude; currentCameraDistance = originalCameraDistance; CameraMove(); }
void ApplyCameraParameters(CameraFollowParameters parameters) { cameraOffset = parameters.cameraOffset; focalDistance = parameters.focalDistance; smoothFactor = parameters.smoothFactor; targetHeight = parameters.targetHeight; }
CameraFollowParameters StoreCameraParameters() { var previousParameters = new CameraFollowParameters(); previousParameters.cameraOffset = cameraOffset; previousParameters.focalDistance = focalDistance; previousParameters.smoothFactor = smoothFactor; previousParameters.targetHeight = targetHeight; return(previousParameters); }
void InitCameraParameters() { defaultParameters = StoreCameraParameters(); // aiming aimingParameters.cameraOffset = new Vector3(0.6f, 0.5f, -0.5f); aimingParameters.focalDistance = 20.0f; aimingParameters.targetHeight = 2.0f; aimingParameters.smoothFactor = 0.1f; // lookback lookbackParameters.cameraOffset = new Vector3(0.2f, 0.5f, 4.0f); lookbackParameters.focalDistance = -10.0f; lookbackParameters.targetHeight = 2.0f; lookbackParameters.smoothFactor = 0.2f; //overviewParameters //frenzyParameters; }