ue-physics-collision

Use when implementing collision detection, trace queries, physics simulation, or physical interactions in Unreal Engine. Triggers on: 'collision', 'trace', 'LineTrace', 'line trace', 'overlap', 'physics', 'hit result', 'sweep', 'collision channel', 'physics body', 'Chaos', 'raytrace', 'OnHit', 'OnBe

By quodsoler · 826 installs

npx skills add quodsoler/unreal-engine-skills --skill ue-physics-collision

Source repository · Upstream listing

UE Physics & Collision Target engine: UE 5.8 . APIs below are verified against the 5.8 headers; older forms are listed under "Deprecated — do not use". Collision and physics live in the Engine module ( UPrimitiveComponent , UWorld queries, FHitResult , UCollisionProfile ) and the PhysicsCore module ( FCollisionShape , UPhysicalMaterial , FBodyInstanceCore , ECollisionTraceFlag , EPhysicalSurface ). The simulator itself is Chaos ( Chaos / ChaosSolverEngine modules); destruction adds GeometryCollectionEngine and FieldSystemEngine . Most gameplay code only needs "Engine" and "PhysicsCore" in Build.cs . Context Read .agents/ue project context.md if it exists (module names, conventions, enabled plugins, GAS/networking setup). Do not stop if it is missing. Identify the area from the request and the codebase. Ask only when two plausible readings would produce different code. Request is about… Go to Channels, profiles, DefaultEngine.ini , responses [Collision Channels and Profiles]( collision channels and profiles) Line traces, sweeps, overlap queries, async traces [Trace Sweep and Overlap Queries]( trace sweep and overlap queries) Reading what a query hit [FHitResult]( fhitresult) OnComponentHit , OnComponentBeginOverlap , wake/sleep [Collision Events]( collision events) Rigid bodies, impulses, forces, mass, damping, sleeping [Physics Bodies and Forces]( physics bodies and forces) Joints, radial force fields, ragdolls [Constraints Radial Force and Ragdolls]( constraints radial force and ragdolls) Friction, restitution, surface types [Physical Materials]( physical materials) Solver settings, substepping, CVars, physics thread ticks [Chaos Solver and Async Physics]( chaos solver and async physics) Replicated physics, resimulation, predictive interpolation [Network Physics]( network physics) Collision Channels and Profiles ECollisionChannel ( Engine/EngineTypes.h:1098 ) has 8 engine channels, 6 hidden engine slots and 50 game slots (64 total; ECC GameTraceChannel50 at :1168 ): Object channel — every component has exactly one, set with SetCollisionObjectType . Matched by ByObjectType queries. Trace channel — never an object type; a query passes it to ByChannel and each component's response to that channel decides block/overlap/ignore. ECollisionResponse ( Engine/EngineTypes.h:1346 ): ECR Ignore , ECR Overlap , ECR Block . ECollisionEnabled::Type ( Engine/EngineTypes.h:1805 ): NoCollision , QueryOnly , PhysicsOnly , QueryAndPhysics , ProbeOnly , QueryAndProbe . SetCollisionProfileName overwrites every manual response, so apply the profile first and the per channel overrides after. Engine profiles shipped in Config/BaseEngine.ini under [/Script/Engine.CollisionProfile] : NoCollision , BlockAll , OverlapAll , BlockAllDynamic , OverlapAllDynamic , IgnoreOnlyPawn , OverlapOnlyPawn , Pawn , Spectator , CharacterMesh , PhysicsActor , Destructible , InvisibleWall , InvisibleWallDynamic , Trigger , Ragdoll , Vehicle , UI , WaterBodyCollision . Custom channels and profiles are config only — there is no runtime API to create one: bTraceType=True declares a trace channel, False an object channel. +Profiles= adds or replaces a whole profile; +EditProfiles= only patches responses on an existing one ( Engine/CollisionProfile.h:160 190 ). UCollisionProfile::Get() reads the table and UCollisionProfile::LoadProfileConfig(bool bForceInit) ( Engine/CollisionProfile.h:237 ) re reads it after a config change. See [collision channel setup.md](references/collision channel setup.md) for full profile sets, the ini reference and a debugging checklist. Trace Sweep and Overlap Queries All world queries are const members of UWorld ( Engine/World.h:2128 2441 ). Three families, each in Test / Single / Multi form: Suffix Selects by Extra parameter ByChannel the querier's trace channel vs each component's response ECollisionChannel TraceChannel , optional FCollisionResponseParams ByObjectType the target component's object channel const FCollisionObjectQueryParams& ByProfile the channel and responses stored in a named profile FName ProfileName TraceTag is the first constructor argument; it also drives the TraceTagAll / named tag debug drawing in the console. Sweeps take a rotation and an FCollisionShape ( PhysicsCore/Public/CollisionShape.h:284 316 ): GetCapsuleHalfHeight() includes the end radius; GetCapsuleAxisHalfLength() is the shaft only. Overlaps are stationary shape tests returning FOverlapResult ( Engine/OverlapResult.h:12 ): OverlapAnyTestByChannel stops at the first block or touch; OverlapBlockingTestByChannel ignores touches. When the query is "what is my own component already touching", use UPrimitiveComponent::GetOverlappingActors or ComponentOverlapComponent instead of a world query. Async traces queue this frame and are readable next frame ( Engine/World.h:2522 , WorldCollision.h:148 ): Passing a FTraceDelegate ( DECLARE DELEGATE TwoParams(FTraceDelegate, const FTraceHandle&, FTraceDatum&) ) instead calls you back when the batch completes. See [trace patterns.md](references/trace patterns.md) for hitscan, melee sweep, interaction, ground check, AoE, line of sight and async sensor patterns, plus the Blueprint layer UKismetSystemLibrary wrappers and performance guidance. FHitResult Engine/HitResult.h . Actor is no longer a member — the actor is reached through an accessor. For a Multi query only the last element can be a blocking hit; every earlier element is a touch. Collision Events Delegates are sparse dynamic multicast, so handlers must be UFUNCTION() declared in the header with exactly the delegate's parameter list, or AddDynamic fails to bind at runtime. Signatures from Components/PrimitiveComponent.h:274 282 and GameFramework/Actor.h:194 196 : Delegate Parameters FComponentHitSignature UPrimitiveComponent HitComponent, AActor OtherActor, UPrimitiveComponent OtherComp, FVector NormalImpulse, const FHitResult& Hit FComponentBeginOverlapSignature UPrimitiveComponent OverlappedComponent, AActor OtherActor, UPrimitiveComponent OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult FComponentEndOverlapSignature UPrimitiveComponent OverlappedComponent, AActor OtherActor, UPrimitiveComponent OtherComp, int32 OtherBodyIndex FComponentWakeSignature / FComponentSleepSignature UPrimitiveComponent WakingComponent ( SleepingComponent ), FName BoneName FActorBeginOverlapSignature / FActorEndOverlapSignature AActor OverlappedActor, AActor OtherActor FActorHitSignature AActor SelfActor, AActor OtherActor, FVector NormalImpulse, const FHitResult& Hit Requirements: overlaps need ECR Overlap on at least one side, a non ECR Ignore pair, and SetGenerateOverlapEvents(true) on both components ( bGenerateOverlapEvents is private — Components/PrimitiveComponent.h:429 ). Simulation hits need ECR Block on both, QueryAndPhysics or PhysicsOnly , and SetNotifyRigidBodyCollision(true) on the simulating component; a swept move ( SetActorLocation(..., true) , movement components) fires OnComponentHit on any blocking hit without that flag ( PrimitiveComponent.cpp:3540 3550 ). OnComponentWake / OnComponentSleep need bGenerateWakeEvents on the body ( PhysicsCore/Public/BodyInstanceCore.h:59 ). Physics Bodies and Forces bVelChange=true / bAccelChange=true ignore mass. ERadialImpulseFalloff is RIF Constant or RIF Linear ( PhysicsCore/Public/Chaos/ChaosEngineInterface.h:90 ). MyMesh GetBodyInstance() reaches the body. FBodyInstanceCore flags ( PhysicsCore/Public/BodyInstanceCore.h ): bSimulatePhysics (:30), bOverrideMass (:35), bEnableGravity (:39), bUpdateKinematicFromSimulation (:43), bAutoWeld (:51), bStartAwake (:55), bGenerateWakeEvents (:59). FBodyInstance adds bUseCCD (:418), bNotifyRigidBodyCollision (:440), LinearDamping (:629), MassScale (:645), InertiaTensorScale (:653), SleepFamily (:410) and CustomSleepThresholdMultiplier (:696). ESleepFamily ( Chaos/ChaosEngineInterface.h:101 ) is Normal , Sensitive or Custom ; only Custom reads the multiplier. Collision complexity comes from ECollisionTraceFlag ( PhysicsCore/Public/BodySetupEnums.h:13 20 ): CTF UseDefault , CTF UseSimpleAndComplex , CTF UseSimpleAsComplex , CTF UseComplexAsSimple . Complex as simple bodies cannot simulate. Constraints Radial Force and Ragdolls UPhysicsConstraintComponent ( PhysicsEngine/PhysicsConstraintComponent.h:24 ) wraps an FConstraintInstance ( :73 ) — the same struct a Physics Asset stores per joint. Motion enums are ELinearConstraintMotion ( LCM Free , LCM Limited , LCM Locked ) and EAngularConstraintMotion ( ACM Free , ACM Limited , ACM Locked ). Editor presets are only combinations of these: Fixed locks all six, Hinge frees one angular axis, Prismatic frees one linear axis, Ball and Socket frees all angular. URadialForceComponent ( PhysicsEngine/RadialForceComponent.h:16 ) is the drop in explosion/vacuum component: Radius , Falloff , ImpulseStrength , bImpulseVelChange , bIgnoreOwningActor , ForceStrength , then FireImpulse() (:50) for a one shot and AddObjectTypeToAffect(EObjectTypeQuery) (:54) to filter targets. Ragdolls run through the skeletal mesh's Physics Asset ( UPhysicsAsset::SkeletalBodySetups , ConstraintSetup — PhysicsEngine/PhysicsAsset.h:213 220 ): Physical Materials PhysicsCore/Public/PhysicalMaterials/PhysicalMaterial.h:103 . EPhysicalSurface ( PhysicsCore/Public/Chaos/ChaosEngineInterface.h:20 ) is SurfaceType Default plus SurfaceType1..SurfaceType62 , named in Project Settings Physics. Chaos Solver and Async Physics Chaos is the only physics backend in 5.8. FChaosScene ( PhysicsCore/Public/Chaos/ChaosScene.h:84 ) owns the solver and is driven by SetUpForFrame (:141), StartFrame (:140), EndFrame (:142); WaitPhysScenes (:122) blocks for results. Project settings live on UPhysicsSettings / UPhysicsSettingsCore under [/Script/Engine.PhysicsSettings] : Setting Header Meaning DefaultGravityZ PhysicsSettingsCore.h:25 world gravity, 980 default BounceThresholdVelocity :79 below this, restitution is skipped MaxDepenetrationVelocity :95 caps push out speed; 0 = unlimited bSimulateSkeletalMeshOnDedicatedServer :114 off saves ragdoll cost on servers DefaultShapeComplexity :119 project wide ECollisionTraceFlag SolverOptions :123 FChaosSolverConfiguration bSubstepping / MaxSubstepDeltaTime / MaxSubsteps PhysicsSettings.h:325,341,345 fixes tunnelling and jitter for small fast bodies bTickPhysicsAsync / AsyncFixedTimeStepSize :333,337 fixed rate physics thread PhysicsPrediction :267 FPhysicsPredictionSettings , gates resimulation FChaosSolverConfiguration ( Chaos/Public/ChaosSolverConfiguration.h:51 ) exposes PositionIterations , VelocityIterations , ProjectionIterations , CollisionMarginFraction , CollisionCullDistance , CollisionMaxPushOutVelocity . Diagnostic CVars that exist in 5.8: With bTickPhysicsAsync on, gameplay code that must run in lockstep with the solver uses the async tick instead of Tick : set bAsyncPhysicsTickEnabled in an actor constructor (protected, GameFramework/Actor.h:699 ) or call SetAsyncPhysicsTickEnabled(true) on a component ( ActorComponent.h:1435 ; the component field at Components/ActorComponent.h