A Target Type, derived from BP_TargetType, is a collision handler actor that the collision system uses to handle collision for other actors. Target Type is the base class for all collision handler actors. These actors have functions that can be used to find targets, for example for handling finding targets for the Abilities System.
Adding Collision Target Type to Actor
To add a Collision Target Type for an Actor, you must get a reference to the collision component of the actor that owns the collision target type. For example, if you add a collision target type to a weapon that does not have it’s own collision manager, then you must add the collision target type to the owner of the actor. Which is typically the character that is instigator of the weapon.
However, if the weapon actor has it’s own collision manager component, like for example with projectiles, then you must get a reference to the owning actors collision manager component and add the target type to that actor.
Once you get the reference to the correct collision manager component you can add a collision target type by calling the function “Add Collision Target Type”. There are a few input parameters which you will need to specify in order for this to work. The first is the target type gameplay tag associated with this target type. The second is the target type class that will be spawned & the third parameter is the Performing Actor. For example, if the target type is a collision trace for a weapon, you must set the weapon as the performing actor.
Basic Usage
The flow of logic execution for a collision target type after being added to an actor’s Collision Component is like this:
Add Collision Target Type - adds collision target type for an actor to the collision system component so that the target type can be searched for by tag & used by the component.
Activate Collision - Executes logic associated with the target type.
This is the function that users need to override to create custom functionality for a target type.
Deactivate Collision - Disables the collision when the collision is finished searching for targets. Typically used to disable trace collisions.
On Collision Target Added - This fires when a collision target is first added to the collision manager component. Use this for initializing data or storing references to things used by the target type.
Get Target - Get target will simply return a single target, it is up to the user of the framework to override this function & create the functionality they need to find the target correctly.
Get Targets - Get targets will return multiple targets, it is up to the user of the framework to override this function & create the functionality they need to find the target correctly.
Target Type Properties
The default Target Type class has some default properties that can be used to change the behavior of the target type. Here I will list some of these properties and what their purpose is:
Collision Radius - Used to define the size of the collision. By default this is only used by the collision trace target type class. However, it can be used for any collision target type where the collision radius needs to be adjustable.
Collision Object Types - The object types this collision trace target can collide with
Collision Profile Names to Ignore - If the hit actor has any of these collision profile names, that collision will be ignored.
Gameplay Tags to Ignore - if the hit actor has any of these tags, the collision will be ignored.
Actor Classes to Ignore - If the hit actor is equal to any of these classes, the collision will be ignored.