ACharacter::OnStartCrouch
#include "GameFramework/Character.h"
Access: public
Specifiers: virtual
Description
Called in C++ when the character begins crouching. Also called on non-owning characters via replication when `bIsCrouched` changes. Override to apply camera or mesh adjustments when the character crouches.
Caveats & Gotchas
- • Always call `Super::OnStartCrouch()` — the base implementation lowers the capsule and repositions the mesh. Skipping it will leave the character's collision and visual representation out of sync.
- • This is called on simulated proxies via `OnRep_IsCrouched`, so it runs on all clients. Logic that should only execute for the owning player (e.g. camera shake) must be guarded with `IsLocallyControlled()`.
- • For Blueprint overrides, use `K2_OnStartCrouch` instead. Attempting to override this virtual from a Blueprint-only class is unsupported.
Signature
ENGINE_API virtual void OnStartCrouch(float HalfHeightAdjust, float ScaledHalfHeightAdjust) Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| HalfHeightAdjust | float | Difference between the default capsule half-height and the crouched capsule half-height. | — |
| ScaledHalfHeightAdjust | float | The half-height difference after the component scale is applied. | — |
Return Type
void Example
Lower camera spring arm on crouch C++
void AMyCharacter::OnStartCrouch(float HalfHeightAdjust, float ScaledHalfHeightAdjust)
{
Super::OnStartCrouch(HalfHeightAdjust, ScaledHalfHeightAdjust);
if (CameraBoom)
{
// Lower camera by the capsule height reduction
CameraBoom->TargetOffset.Z = -ScaledHalfHeightAdjust;
}
} Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?