Appearance
How to coordinate components with UMotionSubsystem
Use this guide when gameplay code needs to query or coordinate Motion components for the local player.
Get the subsystem
cpp
UMotionSubsystem* Subsystem = ULocalPlayer::GetSubsystem<UMotionSubsystem>(
PlayerController->GetLocalPlayer()
);Always check the returned pointer before using it.
Query a component
cpp
UMotionSprintingComponent* SprintComp = Cast<UMotionSprintingComponent>(
Subsystem->GetComponentByClass(UMotionSprintingComponent::StaticClass())
);Use this when code needs current component state without storing hard references.
Coordinate gameplay logic
cpp
if (SprintComp && SprintComp->IsCurrentlySprinting())
{
return;
}
ApplySlowEffect();Keep cross-component decisions in the system that owns the gameplay rule. Use the subsystem as a registry, not as a replacement for component APIs.
Debug registered components
cpp
for (UMotionComponentBase* Component : Subsystem->GetActiveComponents())
{
UE_LOG(LogTemp, Log, TEXT("Motion component: %s"), *Component->GetClass()->GetName());
}