When I crouch it works, but when I uncrouch, the only thing not working is the camera being put back to place.
This is the code:
private void FixedUpdate() {
var desiredHeight = crouching ? crouchHeight : standHeight;
if (_controller.height != desiredHeight) {
AdjustHeight(desiredHeight);
var camPos = playerView.transform.position;
camPos.y = _controller.height;
playerView.transform.position = camPos;
}
}
private void AdjustHeight(float height) {
float center = height / 2f;
_controller.height = Mathf.Lerp(_controller.height, height, crouchSpeed);
_controller.center = Vector3.Lerp(_controller.center, new Vector3(0, center, 0), crouchSpeed);
}