#Can't Stop Crouching After Crouching

1 messages · Page 1 of 1 (latest)

sterile nexus
#

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);
    }
#

Also, other gameObjects that are attached to the Player don't go back up.