private void UpdateCameraPosition(float speed) { Vector3 newCameraPosition; if (!m_UseHeadBob) { return; } if (m_CharacterController.velocity.magnitude > 0 && m_CharacterController.isGrounded) { m_Camera.transform.localPosition = m_HeadBob.DoHeadBob(m_CharacterController.velocity.magnitude + (speed * (m_IsWalking ? 1f : m_RunstepLenghten))); newCameraPosition = m_Camera.transform.localPosition; newCameraPosition.y = m_Camera.transform.localPosition.y - m_JumpBob.Offset(); } else { newCameraPosition = m_Camera.transform.localPosition; newCameraPosition.y = m_OriginalCameraPosition.y - m_JumpBob.Offset(); } m_Camera.transform.localPosition = newCameraPosition; }
private void UpdateHeadBobPosition(float speed) { Vector3 newCameraPosition; if (!m_UseHeadBob) { return; } if (m_CharacterController.velocity.magnitude > 0 && m_CharacterController.isGrounded) { m_HeadBobObject.transform.localPosition = m_HeadBob.DoHeadBob(m_CharacterController.velocity.magnitude + ((m_IsWalking ? 1f : m_RunstepLenghten))); newCameraPosition = m_HeadBobObject.transform.localPosition; newCameraPosition.y = m_HeadBobObject.transform.localPosition.y; } else { newCameraPosition = m_HeadBobObject.transform.localPosition; } newCameraPosition.z = m_OriginalHeadBobPosition.z; m_HeadBobObject.transform.localPosition = newCameraPosition; }
void UpdateCameraPosition(float speed) { Vector3 newCameraPosition; if (!_useHeadBob) { return; } if (_characterController.velocity.magnitude > 0 && _characterController.isGrounded) { _camera.transform.localPosition = _headBob.DoHeadBob(_characterController.velocity.magnitude + (speed * (_isWalking ? 1f : _runstepLenghten))); newCameraPosition = _camera.transform.localPosition; newCameraPosition.y = _camera.transform.localPosition.y - _jumpBob.Offset(); } else { newCameraPosition = _camera.transform.localPosition; newCameraPosition.y = _originalCameraPosition.y - _jumpBob.Offset(); } _camera.transform.localPosition = newCameraPosition; }
private void Update() { Vector3 newCameraPosition; if (rigidbodyFirstPersonController.Velocity.magnitude > 0 && rigidbodyFirstPersonController.Grounded) { Camera.transform.localPosition = motionBob.DoHeadBob(rigidbodyFirstPersonController.Velocity.magnitude * (rigidbodyFirstPersonController.Running ? RunningStrideLengthen : 1f)); newCameraPosition = Camera.transform.localPosition; newCameraPosition.y = Camera.transform.localPosition.y - jumpAndLandingBob.Offset(); } else { newCameraPosition = Camera.transform.localPosition; newCameraPosition.y = m_OriginalCameraPosition.y - jumpAndLandingBob.Offset(); } Camera.transform.localPosition = newCameraPosition; if (!m_PreviouslyGrounded && rigidbodyFirstPersonController.Grounded) { StartCoroutine(jumpAndLandingBob.DoBobCycle()); } m_PreviouslyGrounded = rigidbodyFirstPersonController.Grounded; }