RealDocs

UCharacterMovementComponent::StartSwimming

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

Description

Handles the internal transition from another movement mode (typically walking or falling) into MOVE_Swimming, consuming the remaining time budget for the current physics step.

Caveats & Gotchas

  • • This is a mid-tick transition helper, not a public 'enter water' entry point — call SetMovementMode(MOVE_Swimming) instead if you just want to force swimming from gameplay code.
  • • Consumes and continues simulating remainingTime after the transition, so it can end up calling into the swimming physics for the same frame the character entered water.
  • • Relies on the physics volume's fluid friction/buoyancy settings; behaviour changes significantly if the character enters a custom PhysicsVolume with non-default BuoyancyCoefficient or FluidFriction.

Signature

virtual void StartSwimming(FVector OldLocation, FVector OldVelocity, float timeTick, float remainingTime, int32 Iterations);

Parameters

Name Type Description Default
OldLocation FVector Location on the last tick before entering water. —
OldVelocity FVector Velocity at the last tick before entering water. —
timeTick float Time elapsed since OldLocation. —
remainingTime float Remaining DeltaTime to complete the transition into swimming. —
Iterations int32 Current physics sub-step iteration count. —

Return Type

void

Example

Logging transitions into swimming C++
void UMyCharacterMovementComponent::StartSwimming(FVector OldLocation, FVector OldVelocity, float timeTick, float remainingTime, int32 Iterations)
{
	UE_LOG(LogTemp, Verbose, TEXT("Entering swim mode with %f seconds remaining in this step"), remainingTime);
	Super::StartSwimming(OldLocation, OldVelocity, timeTick, remainingTime, Iterations);
}

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.