Characters can focus on a targeted character in order to track it and direct their attacks towards them.
On top of that, the Melee module also allows to cycle through a list of candidate targets.
To add new candidate targets, use the Add Target Candidate instruction. To remove it, use the Remove Target Candidate instruction.
When to Add/Remove Candidates
In most cases you'll want to set Player target candidates as soon as the enemy appears, and remove the candidate when the enemy dies. To do so, simply add an On Start Trigger on the enemy that adds itself to the Player's candidates, and another Trigger set to On Destroy that removes itself from the Player's target Candidates.
If your game doesn't require to cycle through targets, you can skip all this and simply use the Set Target instruction to focus a character onto a specific enemy. You can also use the Clear Target to remove its current targeted character.
Cycling Through Candidates¶
Once a character has more than 1 candidate target, it can cycle through its list to focus on a particular one. There are multiple ways to cycle through a list of candidates:
Focuses on the closest candidate to the character. This is useful for auto-targeting enemies in fast-paced games where the enemy that's closest to the player should be prioritized.
Use the Cycle Closest instruction to automatically select the one that's closest to the character.
Next / Previous Candidate¶
Focuses on the next or previous character from its internal list. This is usually done in games with few enemies on screen where the right joystick is used for something else other than targeting. For example, pressing the left shoulder button to cycle through the list of enemies.
Use the Cycle Next and Cycle Previous instruction to automatically select the next or previous target.
Repeatedly calling the Next or Previous candidate will circle back to the first or last position upon reaching the other end. For example, if there's a 3 candidate list of enemies, and we're currently focusing on the 3rd and run the Cycle Next instruction, it will jump back to the first position and focus on the first candidate on the list.
Cycle by Direction¶
Focuses on the next candidate that most closely matches the direction given in screen-space from the character's position and the camera reference provided. This is intended to be used with gamepads that have a right-stick that you can use to select the next target.
Use the Cycle Direction Target instruction to select the next candidate based on the camera's perspective and direction provided.