Skip to content

3. TargetComponent Overview

J1blCblu edited this page Oct 31, 2023 · 4 revisions

Note It's assumed that you've already read the Core Concepts.

General Overview

TargetComponent represents a Target that LockOnTargetComponent can capture in conjunction with a Socket. It is kind of a dumping ground for anything LockOnTarget subsystems may need. E.g., a custom widget to be displayed on the screen or a custom capture radius for a large Target. Provides state callbacks to the owner.

Simply put, TargetComponent simply adds a Target tag to any Actor, allowing it to be captured by any LockOnTargetComponent.

When any LockOnTargetComponent captures a Target, TargetComponent stores it in the Invaders set. In standalone games, most of the time there is only one Invader, while in multiplayer games there can be several.

You can retrieve all Target through the TargetManager world subsystem.

Socket and Focus Location Concept

  • Socket Location - should be used when you need the exact position of a captured Target. For example, WeightedTargetHandler uses it to find the best Target by calculating a modifier, WidgetExtension uses it attach a Widget.

  • Focus Point Location - should be primarily used in camera systems for Target tracking. For example, imagine you have captured a giant's leg, but you can't see what attack it's trying to make, then you can move the focus point to where you can see most of the giant.

By default, these locations are the same. You can specify a custom Socket or override GetCustomFocusPoint().

Component Usage

TargetComponent itself doesn't perform any actions.

Useful gameplay methods:

  • IsCaptured() - whether the Target is captured by any LockOnTargetComponent.

  • SetCanBeCaptured() - updates the capture state of the Target. If false, LockOnTargetComponent will clear the Target.

  • Add/RemoveSocket() - adds/removes a particular Socket. For example, if the Target lost an arm, or a robot part was destroyed.

  • UpdateTrackedMesh() - updates TrackedMesh. For example, when the boss has entered into the second phase and you need to change the mesh.

Clone this wiki locally