The BP_SweepingSocketTraceTarget class in the Collision Manager system is a Blueprint class derived from BP_TraceTarget, designed to handle precise collision tracing for sweeping melee attacks, such as weapon swings or fist strikes, in Action RPGs. It enables developers to create accurate hit detection by tracing along a mesh’s sockets, ensuring collisions align with attack animations. This class addresses the need for realistic, mesh-based collision detection, integrating with the BP_CollisionComponent to support dynamic combat mechanics.
Basic Usage
The BP_SweepingSocketTraceTarget is used by adding it to a BP_CollisionComponent, setting a mesh and sockets, and activating it via animations or abilities. Below are the primary functions for interacting with it in Blueprints.
-
ActivateCollision:
- Purpose: Starts the tick-based collision trace along the specified mesh sockets.
- Usage: Call via
ActivateCollisionByTagonBP_CollisionComponent, often triggered byANS_CollisionTrace.
-
DeactivateCollision:
- Purpose: Stops the collision trace and cleans up.
- Usage: Call via
DeactivateCollisionByTagor automatically viaANS_CollisionTracewhen the animation ends.
-
CollisionTrace:
- Purpose: Performs the tick-based trace along the mesh’s socket paths to detect hits.
- Usage: Override in a child Blueprint to customize trace behavior (e.g., adjust trace shape or path).
-
OnHit:
- Purpose: Executes logic when the trace hits a valid target.
- Usage: Override to apply
Gameplay Effectsor trigger events on hit.
-
SetCollisionProperties:
- Purpose: Configures the mesh and sockets for tracing.
- Usage: Call after adding the target type to set the weapon mesh and socket names.
Key Properties
| Property Name | Purpose |
|---|---|
Collision Radius | Defines the radius of the trace (e.g., for sphere or capsule traces); adjusts hit detection size. |
Collision Object Types | Specifies object types the trace can collide with (e.g., Pawn, WorldStatic). |
Collision Profile Names to Ignore | Ignores hits from actors with these collision profile names. |
Gameplay Tags to Ignore | Ignores hits from actors with any of these Gameplay Tags. |
Actor Classes to Ignore | Ignores hits from actors of these classes. |
Draw Debug Type | Sets debug visibility for the trace (e.g., For One Frame, Persistent); used for testing. |
Key Concepts
Mesh-Based Socket Tracing
The BP_SweepingSocketTraceTarget traces collisions along paths defined by a mesh’s sockets (e.g., blade start to end), ensuring hit detection matches the weapon’s visual motion. This is ideal for melee attacks requiring precise, animation-driven hit boxes.
- Purpose: Aligns collision detection with weapon mesh animations for realistic combat.
- Usage: Set the mesh and sockets via
SetCollisionPropertiesand activate viaANS_CollisionTrace. - Benefit: Enhances visual fidelity and hit accuracy for melee attacks.
Animation-Driven Collision
The class integrates with ANS_CollisionTrace to activate/deactivate traces during specific animation frames, ensuring collisions occur only when the attack visually connects. This ties hit detection to animation timing.
- Purpose: Synchronizes hit boxes with attack animations.
- Usage: Use
ANS_CollisionTracein animations with the correctCollision Target Tag. - Benefit: Improves gameplay feel by matching collision to visual cues.
Customizable Hit Responses
The OnHit event allows developers to define custom responses to hits, such as applying Gameplay Effects or spawning Gameplay Cues. This flexibility supports varied combat mechanics, like different damage types or status effects.
- Purpose: Enables tailored hit reactions for specific weapons or abilities.
- Usage: Override
OnHitin a child Blueprint to implement custom logic. - Benefit: Supports diverse combat interactions with minimal setup.
Best Practices
- Workflows:
- Use
BP_SweepingSocketTraceTargetfor melee weapons with skeletal meshes, reservingBP_TraceTargetfor non-mesh-based traces. - Define clear socket names (e.g.,
BladeStart,BladeEnd) in the mesh to simplifySetCollisionPropertiessetup. - Test with
ANS_CollisionTraceand debug visuals (Draw Debug Type) to ensure traces align with animations.
- Use
- Pitfalls to Avoid:
- Always call
SetCollisionPropertieswith valid mesh and sockets; missing sockets cause trace failures. - Don’t leave traces active beyond their intended duration; use
DeactivateCollisionByTagorANS_CollisionTraceto stop them. - Avoid excessive socket counts in
SetCollisionPropertiesto prevent performance overhead.
- Always call
- Performance Considerations:
- Minimize active
BP_SweepingSocketTraceTargetinstances by deactivating unused traces promptly. - Use
Collision Profile Names to IgnoreandGameplay Tags to Ignoreto filter irrelevant hits. - Set
Draw Debug TypetoNonein production to eliminate debug rendering costs.
- Minimize active