RealDocs

UCharacterMovementComponent::PhysicsVolumeChanged

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

Description

Called by the engine whenever the character's UpdatedComponent enters a new physics volume. Switches the character into Swimming mode when entering a water volume, or into Falling mode (with an optional water-jump) when leaving one.

Caveats & Gotchas

  • If the character enters a water volume but CanEverSwim() is false, it does not switch to swimming — instead it notifies the path-following agent that it's unable to move, which can silently strand AI-controlled characters in water.
  • Overriding this without calling Super::PhysicsVolumeChanged() disables the automatic Swimming/Falling mode transitions entirely, which most custom movement components still rely on.

Signature

virtual void PhysicsVolumeChanged(class APhysicsVolume* NewVolume) override

Parameters

Name Type Description Default
NewVolume class APhysicsVolume* The physics volume the character has just entered; may be the world's default volume.

Return Type

void

Example

Extend the water-entry/exit behavior C++
void UMyCharacterMovementComponent::PhysicsVolumeChanged(APhysicsVolume* NewVolume)
{
	Super::PhysicsVolumeChanged(NewVolume);
	if (NewVolume && NewVolume->bWaterVolume)
	{
		UE_LOG(LogTemp, Log, TEXT("Character entered water volume %s"), *NewVolume->GetName());
	}
}

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.