Movement boost
The burst-speed pattern from Example 15: temporarily raise MaxWalkSpeed, schedule a restore with SetTimer.
uclass AExampleMover : AActor meta: api=MYGAME_API
{
prop public float BoostMultiplier EditAnywhere BlueprintReadWrite category="Movement" default=2.0f
prop public float BoostDuration EditAnywhere BlueprintReadWrite category="Movement" default=5.0f
field public FTimerHandle BoostResetTimer
func public void ApplyBoost(ACharacter* Char) BlueprintCallable category="Movement"
{
if (Char && Char->GetCharacterMovement())
{
UCharacterMovementComponent* M = Char->GetCharacterMovement();
M->MaxWalkSpeed *= BoostMultiplier;
GetWorldTimerManager().SetTimer(
BoostResetTimer,
[this, Char, M]()
{
if (IsValid(M)) { M->MaxWalkSpeed /= BoostMultiplier; }
},
BoostDuration, false);
}
}
}
Why it's robust
- No per-frame logic - the timer fires once.
- Self-restoring - dividing back by the same multiplier returns the original speed.
- Guarded -
IsValid(M)avoids touching a destroyed component. - Designer-tuned - multiplier and duration are
EditAnywhere.
Extend it
- Cancel early:
GetWorldTimerManager().ClearTimer(BoostResetTimer); - Add a cooldown by clearing/re-setting the same handle.
Includes: GameFramework/Character.h, GameFramework/CharacterMovementComponent.h, TimerManager.h.
Next recipe: Making a designer hook.