This guide provides step-by-step instructions for integrating the Collision Manager
into an Unreal Engine 5 project, enabling trace hit detection and target selection for weapons and abilities in Action RPGs. Users will learn how to set up the system, add default collision target types to actors, and test core functionality using preconfigured assets. The guide focuses on enabling the system as it functions in the demo content, ensuring developers and designers can quickly implement collision and targeting mechanics.
Prerequisites
- Unreal Engine 5.3 or later.
- Enhanced Input System enabled (default in UE5 templates).
- A pawn Blueprint (e.g.,
BP_PlayerCharacter
) and a weapon Blueprint (e.g.,BP_Sword
) for testing collisions. - No additional plugins required.
Integration Steps
-
Migrate the CollisionSystem Folder:
- In the Unreal Editor, open the demo project containing the
Collision Manager
. - In the Content Browser, locate the
CollisionSystem
folder. - Right-click and select Migrate, then choose your project’s
Content
directory. - Ensure all dependencies (e.g., Blueprints, Animation Notifies) are copied correctly.
- In the Unreal Editor, open the demo project containing the
-
Add
BP_CollisionComponent
to Actor:- Open your pawn Blueprint (e.g.,
BP_PlayerCharacter
). - In the Components panel, click Add Component and select
BP_CollisionComponent
. - In the Details panel of
BP_CollisionComponent
, add default target types to theDefaultTargetTypes
array (e.g.,BP_TraceTarget
with tagCollision.DefaultTrace
) orDefaultTargetTypeMap
(e.g., mapCollision.SwordTrace
toBP_SweepingSocketTraceTarget
).
- Open your pawn Blueprint (e.g.,
NOTE:
If using with Advanced ARPG Combat System, default collision component target types are configured through the Enemy Info Data Asset and Player Info Data Asset by default for enemies and players
- Configure Weapon with Default Collision:
- Open your weapon Blueprint (e.g.,
BP_Sword
). - Ensure it has a
SkeletalMeshComponent
with sockets defined (e.g.,StartSocket
,EndSocket
) forBP_SweepingSocketTraceTarget
. - In the weapon’s Class Defaults, search for
Collision Trace Class
and set the default target type for the weapon:
- Open your weapon Blueprint (e.g.,
// Class Defaults | Initialization
- CollisionTraceTarget = BP_MyCollisionTraceTarget
- Optionally, in the weapon’s Event Graph, on
Event BeginPlay
, get the owner’sBP_CollisionComponent
and add a default target type:
Event BeginPlay -> Get Owner -> Get Component By Class (Class: BP_CollisionComponent) -> AddCollisionTargetType (TargetTypeTag: Collision.SwordTrace, TargetTypeClass: BP_SweepingSocketTraceTarget, PerformingActor: Self)
- Call
SetCollisionProperties
to set the weapon mesh and sockets:
AddCollisionTargetType -> SetCollisionProperties (Mesh: SkeletalMeshComponent, Sockets: StartSocket, EndSocket)
-
Set Up Animation Notify for Melee Collision:
- Open an attack animation (e.g.,
Anim_SwordSwing
) included in the demo content. - Add an
ANS_CollisionTrace
Anim Notify State to the desired frames where the attack should detect hits. - In the Notify’s Details panel, set:
Collision Target Tag
:Collision.SwordTrace
Attack Data
: Optional; leave as null to use default trace settings.Trace Radius Modifier
: 0 (or adjust for wider/narrower traces).
- Verify the animation is assigned to an Animation Blueprint used by
BP_PlayerCharacter
.
- Open an attack animation (e.g.,
-
Configure Enhanced Input for Ability Targeting:
- In Project Settings > Input, create an Input Action (e.g.,
IA_TargetAbility
). - Create an Input Mapping Context (e.g.,
IMC_Combat
) and mapIA_TargetAbility
to a key (e.g., Left Mouse Button). - In
BP_PlayerCharacter
’s Event Graph, onEvent BeginPlay
, add theIMC_Combat
mapping context:
- In Project Settings > Input, create an Input Action (e.g.,
Event BeginPlay -> Get Player Controller -> Add Mapping Context (IMC_Combat)
- Bind
IA_TargetAbility
to query targets usingFindTargetsByClass
:
Enhanced Input Action (IA_TargetAbility) -> Get Component By Class (Class: BP_CollisionComponent) -> FindTargetsByClass (Class: BP_TargetType) -> Store Targets for Ability
- Test with Default Assets:
- Place
BP_PlayerCharacter
in a level with a weapon (e.g.,BP_Sword
) equipped. - Ensure
BP_CollisionComponent
onBP_PlayerCharacter
has a default target type (e.g.,BP_SweepingSocketTraceTarget
forCollision.SwordTrace
). - Add an enemy actor (e.g.,
BP_Enemy
) from the demo content to the level. - Play the level and trigger the attack animation (via input or ability) to test melee collision; verify hits register (e.g., enemy takes damage).
- Press the
IA_TargetAbility
key to test target selection; confirm a target is returned for ability use.
- Place
Troubleshooting
- Collisions Don’t Register:
- Verify
BP_CollisionComponent
is added to the owning actor (e.g.,BP_PlayerCharacter
) and initialized withDefaultTargetTypes
orAddCollisionTargetType
. - Ensure
BP_SweepingSocketTraceTarget
has valid sockets set viaSetCollisionProperties
. - Check that
ANS_CollisionTrace
uses the correctCollision Target Tag
matching the target type.
- Verify
- Target Selection Fails:
- Confirm
FindTargetsByClass
uses the correctBP_TargetType
class and the actor has aBP_CollisionComponent
. - Ensure
Collision Object Types
andGameplay Tags to Ignore
in the target type are set to include desired targets.
- Confirm
- Animation Notify Not Triggering:
- Verify the animation is played via the Animation Blueprint and
ANS_CollisionTrace
is placed on the correct frames. - Check that the
Collision Target Tag
inANS_CollisionTrace
matches the target type tag inBP_CollisionComponent
.
- Verify the animation is played via the Animation Blueprint and
Best Practices
- Workflows:
- Use
DefaultTargetTypeMap
orDefaultTargetTypes
inBP_CollisionComponent
to preconfigure common target types for quick setup. - Test collision with demo assets (e.g.,
BP_Sword
,Anim_SwordSwing
) before integrating with custom animations or weapons.
- Use
- Pitfalls to Avoid:
- Always call
DeactivateCollisionByTag
forBP_TraceTarget
orBP_SweepingSocketTraceTarget
to stop tracing and prevent performance issues. - Don’t skip setting
Performing Actor
inAddCollisionTargetType
for weapons, as it’s required for correct collision context. - Avoid adding
BP_CollisionComponent
to weapons unless necessary (e.g., projectiles); use the owner’s component instead.
- Always call
- Performance Considerations:
- Limit the number of active
BP_TraceTarget
orBP_SweepingSocketTraceTarget
instances by deactivating unused traces. - Use
Collision Profile Names to Ignore
andActor Classes to Ignore
to reduce unnecessary collision checks. - Set
Draw Debug Type
toNone
in production to disable debug visuals forBP_TraceTarget
.
- Limit the number of active