Unreal Engine 5.7 — Physics Module Reference
Unreal Engine 5.7 — Physics Module Reference
Last verified: 2026-02-13 Knowledge Gap: UE 5.7 Chaos Physics improvements
Overview
UE 5 uses Chaos Physics (replaced PhysX in UE 4):
- Better performance
- Destruction support
- Vehicle physics improvements
Rigid Body Physics
Enable Physics on Static Mesh
UStaticMeshComponent* MeshComp = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Mesh"));
MeshComp->SetSimulatePhysics(true);
MeshComp->SetEnableGravity(true);
MeshComp->SetMassOverrideInKg(NAME_None, 50.0f); // 50 kg
Apply Forces
// Apply impulse (instant velocity change)
MeshComp->AddImpulse(FVector(0, 0, 1000), NAME_None, true);
// Apply force (continuous)
MeshComp->AddForce(FVector(0, 0, 500));
// Apply torque (rotation)
MeshComp->AddTorqueInRadians(FVector(0, 0, 100));
Collision
Collision Channels
// Project Settings > Engine > Collision
// Define custom collision channels and responses
// Set collision in C++
MeshComp->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics);
MeshComp->SetCollisionObjectType(ECollisionChannel::ECC_Pawn);
MeshComp->SetCollisionResponseToAllChannels(ECR_Block);
MeshComp->SetCollisionResponseToChannel(ECC_Camera, ECR_Ignore);
Collision Events
// Enable collision events
MeshComp->SetNotifyRigidBodyCollision(true);
// Bind to OnComponentHit
MeshComp->OnComponentHit.AddDynamic(this, &AMyActor::OnHit);
UFUNCTION()
void AMyActor::OnHit(UPrimitiveComponent* HitComp, AActor* OtherActor,
UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit) {
UE_LOG(LogTemp, Warning, TEXT("Hit %s"), *OtherActor->GetName());
}
Overlap Events
// Enable overlap events
MeshComp->SetGenerateOverlapEvents(true);
// Bind to OnComponentBeginOverlap
MeshComp->OnComponentBeginOverlap.AddDynamic(this, &AMyActor::OnOverlapBegin);
UFUNCTION()
void AMyActor::OnOverlapBegin(UPrimitiveComponent* OverlappedComp, AActor* OtherActor,
UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult) {
UE_LOG(LogTemp, Warning, TEXT("Overlapped %s"), *OtherActor->GetName());
}
Raycasting (Line Traces)
Single Line Trace
FHitResult HitResult;
FVector Start = GetActorLocation();
FVector End = Start + GetActorForwardVector() * 1000.0f;
FCollisionQueryParams QueryParams;
QueryParams.AddIgnoredActor(this);
// Perform trace
bool bHit = GetWorld()->LineTraceSingleByChannel(
HitResult,
Start,
End,
ECC_Visibility,
QueryParams
);
if (bHit) {
UE_LOG(LogTemp, Warning, TEXT("Hit: %s"), *HitResult.GetActor()->GetName());
DrawDebugLine(GetWorld(), Start, HitResult.Location, FColor::Red, false, 2.0f);
}
Multi Line Trace
TArray<FHitResult> HitResults;
bool bHit = GetWorld()->LineTraceMultiByChannel(
HitResults,
Start,
End,
ECC_Visibility,
QueryParams
);
for (const FHitResult& Hit : HitResults) {
UE_LOG(LogTemp, Warning, TEXT("Hit: %s"), *Hit.GetActor()->GetName());
}
Sweep (Thick Trace)
FHitResult HitResult;
FCollisionShape Sphere = FCollisionShape::MakeSphere(50.0f);
bool bHit = GetWorld()->SweepSingleByChannel(
HitResult,
Start,
End,
FQuat::Identity,
ECC_Visibility,
Sphere,
QueryParams
);
Character Movement
Character Movement Component
// Built into ACharacter class
UCharacterMovementComponent* MoveComp = GetCharacterMovement();
// Configure movement
MoveComp->MaxWalkSpeed = 600.0f;
MoveComp->JumpZVelocity = 600.0f;
MoveComp->AirControl = 0.2f;
MoveComp->GravityScale = 1.0f;
MoveComp->bOrientRotationToMovement = true;
Add Movement Input
// In Character class
void AMyCharacter::MoveForward(float Value) {
if (Value != 0.0f) {
AddMovementInput(GetActorForwardVector(), Value);
}
}
void AMyCharacter::MoveRight(float Value) {
if (Value != 0.0f) {
AddMovementInput(GetActorRightVector(), Value);
}
}
Physical Materials
Create Physical Material
- Content Browser > Right Click > Physics > Physical Material
- Configure properties:
- Friction: 0.0 - 1.0
- Restitution (bounciness): 0.0 - 1.0
Assign Physical Material
// In static mesh editor: Physics > Phys Material Override
// Or in C++:
MeshComp->SetPhysMaterialOverride(PhysicalMaterial);
Constraints (Physics Joints)
Physics Constraint Component
UPhysicsConstraintComponent* Constraint = CreateDefaultSubobject<UPhysicsConstraintComponent>(TEXT("Constraint"));
Constraint->SetConstrainedComponents(ComponentA, NAME_None, ComponentB, NAME_None);
// Configure constraint
Constraint->SetLinearXLimit(ELinearConstraintMotion::LCM_Limited, 100.0f);
Constraint->SetLinearYLimit(ELinearConstraintMotion::LCM_Locked, 0.0f);
Constraint->SetLinearZLimit(ELinearConstraintMotion::LCM_Free, 0.0f);
Constraint->SetAngularSwing1Limit(EAngularConstraintMotion::ACM_Limited, 45.0f);
Destruction (Chaos Destruction)
Enable Chaos Destruction
// Plugin: Enable "Chaos" plugin
// Create Geometry Collection asset for destructible objects
Destroy Geometry Collection
// Fracture mesh in Chaos editor
// In game, apply damage:
UGeometryCollectionComponent* GeoComp = /* Get component */;
GeoComp->ApplyPhysicsField(/* Field parameters */);
Performance Tips
Physics Optimization
// Simplify collision shapes (use simple primitives)
MeshComp->SetCollisionEnabled(ECollisionEnabled::NoCollision); // Disable when not needed
// Use Physics Asset for skeletal meshes (simplified collision)
// Don't simulate physics for distant objects
// Reduce physics substeps:
// Project Settings > Engine > Physics > Max Substep Delta Time
Debugging
Physics Debug Visualization
// Console commands:
// show collision - Show collision shapes
// p.Chaos.DebugDraw.Enabled 1 - Show Chaos debug
// pxvis collision - Visualize collision
// Draw debug shapes:
DrawDebugSphere(GetWorld(), Location, Radius, 12, FColor::Green, false, 2.0f);
DrawDebugBox(GetWorld(), Location, Extent, FColor::Red, false, 2.0f);