What does crouching do to your components?

What does crouching actually do? I know it lowers your viewport, but does do anything than that?

Is my capsule component any smaller?
If it’s not how can I make that happen?

I’m just searching the API. If you use “Crouch” on your Character, it changes a bool on the CharacterMovementComponent:

void ACharacter::Crouch(bool bClientSimulation)
{
    if (CharacterMovement)
    {
        if (CanCrouch())
        {
            CharacterMovement->bWantsToCrouch = true;
        }
    }
}

On the CharacterMovementComponent i found this:

In between these lines you can find this:

// Change collision size to crouching dimensions
    const float ComponentScale = CharacterOwner->GetCapsuleComponent()->GetShapeScale();
    const float OldUnscaledHalfHeight = CharacterOwner->GetCapsuleComponent()->GetUnscaledCapsuleHalfHeight();
    CharacterOwner->GetCapsuleComponent()->SetCapsuleSize(CharacterOwner->GetCapsuleComponent()->GetUnscaledCapsuleRadius(), [CrouchedHalfHeight](API\Runtime\Engine\GameFramework\UCharacterMovementComponent\CrouchedHalfHeight));
    float HalfHeightAdjust = (OldUnscaledHalfHeight - [CrouchedHalfHeight](API\Runtime\Engine\GameFramework\UCharacterMovementComponent\CrouchedHalfHeight));
    float ScaledHalfHeightAdjust = HalfHeightAdjust * ComponentScale;

And at the End this:

// OnStartCrouch takes the change from the Default size, not the current one (though they are usually the same).
    ACharacter* DefaultCharacter = CharacterOwner->GetClass()->GetDefaultObject<ACharacter>();
    HalfHeightAdjust = (DefaultCharacter->GetCapsuleComponent()->GetUnscaledCapsuleHalfHeight() - [CrouchedHalfHeight](API\Runtime\Engine\GameFramework\UCharacterMovementComponent\CrouchedHalfHeight));
    ScaledHalfHeightAdjust = HalfHeightAdjust * ComponentScale;
 
    AdjustProxyCapsuleSize();
    CharacterOwner->OnStartCrouch( HalfHeightAdjust, ScaledHalfHeightAdjust );

Seems like he is changing the collision based on same default values and actual values.

At the End the whole crouching thing calls this on the character:

void ACharacter::OnStartCrouch( float HeightAdjust, float ScaledHeightAdjust )
{
    RecalculateBaseEyeHeight();
 
    if (Mesh)
    {
        Mesh->[RelativeLocation](API\Runtime\Engine\Components\USceneComponent\RelativeLocation).[Z](API\Runtime\Core\Math\FVector\Z) = GetDefault<ACharacter>(GetClass())->Mesh->[RelativeLocation](API\Runtime\Engine\Components\USceneComponent\RelativeLocation).[Z](API\Runtime\Core\Math\FVector\Z) + HeightAdjust;
        [BaseTranslationOffset](API\Runtime\Engine\GameFramework\ACharacter\BaseTranslationOffset).[Z](API\Runtime\Core\Math\FVector\Z) = Mesh->[RelativeLocation](API\Runtime\Engine\Components\USceneComponent\RelativeLocation).[Z](API\Runtime\Core\Math\FVector\Z);
    }
    else
    {
        [BaseTranslationOffset](API\Runtime\Engine\GameFramework\ACharacter\BaseTranslationOffset).[Z](API\Runtime\Core\Math\FVector\Z) = GetDefault<ACharacter>(GetClass())->[BaseTranslationOffset](API\Runtime\Engine\GameFramework\ACharacter\BaseTranslationOffset).[Z](API\Runtime\Core\Math\FVector\Z) + HeightAdjust;
    }
 
    K2_OnStartCrouch(HeightAdjust, ScaledHeightAdjust);
}

:smiley: This is a bit too much for me here, but maybe this helps you. Here are the sources: