RealDocs

ACharacter::GetDefaultHalfHeight

function Engine Since 4.0
#include "GameFramework/Character.h"
Access: public Specifiers: virtualconstoverride

Description

Returns the default (standing) half-height of the Character's CapsuleComponent. This is the unscaled capsule half-height set at construction time, not the current possibly-crouched value.

Caveats & Gotchas

  • Returns the *default* half-height, not the current one — if the character is crouching, the capsule's actual half-height will be smaller. Use `GetCapsuleComponent()->GetScaledCapsuleHalfHeight()` to get the live value.
  • The value comes from `CharacterMovement->DefaultCharacter.CachedDefaultHalfHeight` which is cached in `PostInitializeComponents`; overriding capsule size after that point will not update what this function returns unless you also update the cached value.

Signature

ENGINE_API virtual float GetDefaultHalfHeight() const override;

Return Type

float

Example

Compute eye height offset relative to default standing height C++
float AMyCharacter::ComputeStandingEyeHeight() const
{
    // Eye height is some fraction of the full standing height
    return GetDefaultHalfHeight() * 0.9f;
}

Version History

Introduced in: 4.0

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.