跳至正文
OpenAgentSkill
浏览已开放 · 目录记录日期 2026-11-21 · 自动更新和账户服务暂时关闭。
其他技能

ue-physics-collision

Use when setting up collision channels and profiles, running line/sweep/overlap queries, wiring hit and overlap events, or simulating rigid bodies in Unreal Engine C++. Also use when the user mentions 'collision channel', 'collision profile', 'LineTraceSingleByChannel', 'SweepSingleByChannel', 'OverlapMultiByObjectType', 'FHitResult', 'FCollisionQueryParams', 'FCollisionShape', 'OnComponentHit', 'OnComponentBeginOverlap', 'SetCollisionProfileName', 'SetSimulatePhysics', 'AddRadialImpulse', 'ragdoll', 'Chaos solver', 'ECC_GameTraceChannel1', or 'my overlap never fires'. For component attachment, see ue-actor-component-architecture; for capsule floor checks, see ue-character-movement.

quodsoler · 已有静态检查记录

安装与使用

运行命令前先阅读来源与依赖说明。复制命令不会自动安装或执行。

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

技能说明


name: ue-physics-collision description: "Use when setting up collision channels and profiles, running line/sweep/overlap queries, wiring hit and overlap events, or simulating rigid bodies in Unreal Engine C++. Also use when the user mentions 'collision channel', 'collision profile', 'LineTraceSingleByChannel', 'SweepSingleByChannel', 'OverlapMultiByObjectType', 'FHitResult', 'FCollisionQueryParams', 'FCollisionShape', 'OnComponentHit', 'OnComponentBeginOverlap', 'SetCollisionProfileName', 'SetSimulatePhysics', 'AddRadialImpulse', 'ragdoll', 'Chaos solver', 'ECC_GameTraceChannel1', or 'my overlap never fires'. For component attachment, see ue-actor-component-architecture; for capsule floor checks, see ue-character-movement." metadata: version: "2.0.0" engine: "5.8"

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, responsesCollision Channels and Profiles
Line traces, sweeps, overlap queries, async tracesTrace Sweep and Overlap Queries
Reading what a query hitFHitResult
OnComponentHit, OnComponentBeginOverlap, wake/sleepCollision Events
Rigid bodies, impulses, forces, mass, damping, sleepingPhysics Bodies and Forces
Joints, radial force fields, ragdollsConstraints Radial Force and Ragdolls
Friction, restitution, surface typesPhysical Materials
Solver settings, substepping, CVars, physics-thread ticksChaos Solver and Async Physics
Replicated physics, resimulation, predictive interpolationNetwork 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):

ECC_WorldStatic, ECC_WorldDynamic, ECC_Pawn, ECC_PhysicsBody,
ECC_Vehicle, ECC_Destructible                 // object channels (what a component IS)
ECC_Visibility, ECC_Camera                    // trace channels (what a query LOOKS FOR)
ECC_GameTraceChannel1 ... ECC_GameTraceChannel50  // project slots, either kind
  • 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.
#include "Components/PrimitiveComponent.h"

MyMesh->SetCollisionProfileName(TEXT("BlockAllDynamic"));   // preferred: one call sets everything
MyMesh->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics);
MyMesh->SetCollisionObjectType(ECC_PhysicsBody);
MyMesh->SetCollisionResponseToAllChannels(ECR_Block);
MyMesh->SetCollisionResponseToChannel(ECC_Pawn, ECR_Overlap);
MyMesh->SetCollisionResponseToChannel(ECC_Camera, ECR_Ignore);

FCollisionResponseContainer Responses(ECR_Ignore);
Responses.SetResponse(ECC_Visibility, ECR_Block);
MyMesh->SetCollisionResponseToChannels(Responses);

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:

[/Script/Engine.CollisionProfile]
+DefaultChannelResponses=(Channel=ECC_GameTraceChannel1,DefaultResponse=ECR_Block,bTraceType=True,bStaticObject=False,Name="Weapon")
+DefaultChannelResponses=(Channel=ECC_GameTraceChannel2,DefaultResponse=ECR_Block,bTraceType=False,bStaticObject=False,Name="Interactable")
+Profiles=(Name="MyInteractable",CollisionEnabled=QueryAndPhysics,ObjectTypeName="Interactable",CustomResponses=((Channel="Weapon",Response=ECR_Ignore),(Channel="Visibility",Response=ECR_Block)),HelpMessage="Interactable props")
+EditProfiles=(Name="Pawn",CustomResponses=((Channel="Weapon",Response=ECR_Block)))

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) (`

阅读完整来源 ↗