public void UpdateCameraPosition() { Vector3 newCameraPosition; if (!useHeadBob) { return; } if (charController.velocity.magnitude > 0 && charController.isGrounded) { cam.transform.localPosition = headBob.DoHeadBob(charController.velocity.magnitude + (fpController.DesiredSpeed() * (fpController.IsWalking() ? 1f : runstepLenghten))); newCameraPosition = cam.transform.localPosition; newCameraPosition.y = cam.transform.localPosition.y - jumpBob.Offset(); } else { newCameraPosition = cam.transform.localPosition; newCameraPosition.y = originalCameraPosition.y - jumpBob.Offset(); } cam.transform.localPosition = newCameraPosition; }