RealDocs

UCharacterMovementComponent::SetUpdatedComponent

function Engine Since 4.0
#include "GameFramework/CharacterMovementComponent.h"
Access: public Specifiers: virtualoverride

Description

Assigns the component that this movement component drives, overriding UMovementComponent's base implementation to also cache the owning ACharacter and validate that the component is a capsule where required.

Caveats & Gotchas

  • The new component must be owned by the same Actor as the movement component, or the assignment is rejected and UpdatedComponent is left unchanged.
  • Calling this outside of the normal component-setup flow (e.g. swapping capsules at runtime) can leave cached movement state like Velocity and MovementMode referencing the old component's geometry until the next tick.
  • Overriding this without calling Super::SetUpdatedComponent() breaks CharacterOwner caching, which most of the movement simulation depends on.

Signature

virtual void SetUpdatedComponent(USceneComponent* NewUpdatedComponent) override

Parameters

Name Type Description Default
NewUpdatedComponent USceneComponent* The scene component this movement component should move and rotate.

Return Type

void

Example

Reassigning the updated component C++
void AMyCharacter::SwapCapsule(UCapsuleComponent* NewCapsule)
{
    GetCharacterMovement()->SetUpdatedComponent(NewCapsule);
}

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.