The Combatant component provides extra information that can be used for combat processing. By itself, the Combatant has limited functionality. However, some combat scripts require the participants to have a Combatant component attached so we know they can be attacked.


Combat Center

During combat processing, its sometimes necessary to understand the “combat center” of a character. Typically this is where attacks originate from.

The Combat Transform allows us to specify a transform as the combat center. This is useful to account for when the character crouches, leans, etc. If no value is set, we use the character’s root.

By checking Height Only, we will only use the y-component of the transform when determining the combat center.

We can also use the Combat Offset to adjust the final position of the combat center. This will be relative to the Combat Transform.

Melee Reach is the min and max distance from the combat center that the character can reach (does not include the weapon reach).


Target & Locking

One of the features of the Combatant is that it can be used to specify who the character is targeting.

In addition to simply specifying the opponent we’re tarting, we can also lock onto the target.

By locking on, we can force character rotations, camera rotations, and add an icon to the screen.






Target – Transform that we’re targeting.

Target Locked – Determines if we’re currently locked onto the target.

Is Locking Enabled – Determines if we’re capable of locking onto a target.

Toggle Lock Alias – Unity Input Manager entry used to activate and deactivate a lock. When activating a lock, we’ll find the best target.

Valid Actor Stances – Comma separated list representing the Stances that a character can be in for target locking to work.

Require Combatant – Determines if the potential target needs a Combatant component to be targeted.

Max Distance – Maximum distance that we’ll use when finding targets.

Force Character Direction – Determines if we force the character to rotate towards the target when locked.

Force Camera Direction – Determines if we force the camera to look at the target when locked.

Camera Modes – When using an ootii camera rig, we’ll set the modes when the Combatant locks on and releases the lock. How the camera reacts to the mode depends on the camera logic.

The Camera Controller, for example, will run the motor whose index matches the “mode” value set.

Locked Icon – Icon to show over the target’s combat center when we are locked on.


Finding Targets

When finding targets, the Combatant uses a “cone cast” that starts from the camera’s position and shoots out in the direction of the camera. If no valid target is hit, we begin to spiral the raycasting out until we hit a valid target or we reach the maximum angle.

This way, we don’t have to be looking exactly at a target. However, the targets more towards the center of the view take precedence.



As we move forward, more and more of the ootii assets will support sending messages through Unity Events. This is a great way for you to add customized code to react to in-game actions.

You can also use Reactors to react to these messages and events as well.

The Combatant supports the following messages.

Target Locked – Sent when a target is locked.

Target Unlocked – Sent when the lock on the target is released.





Page Contents