Post 13: Targeting; Part 1
As a common feature in fight sequences, targeting enemy NPCs allows for more fluid movement and enables orbiting which puts the focus on attacking combos. This is definitely what I would like to achieve.
I started by establishing an input, in this case the middle mouse button, although I am impartial to the tab button too. This can change in the future.
I utilised an AI feature where the enemy rotates to face the player when detected as the continual focus and rotation is exactly what I’m after. After making this into an accessible function that would trigger when the input was detected, I needed a way to first search for NPC’s.
I accomplised this by calling a raycast sphere and returning all actors found within.
Next I queried what ‘team’ the actors were a part of (this was implemented last week) and passed out the closest hit as the target of the player.
Finally, I ensured that the player could tap out of the targeting by implementing a system where the bool controlling when the player can target is constantly changing to the opposite of its previous state.
This is a fairly oversimplified account of what I did and there were a bunch of issues I had with bool controlling including some clashing with the Toggle Walking (Would only activate once), crouching (Would get stuck in crouch) and Jumping (Would stall the player entirely). However, these were fixed with some added bools.
I would like to implement a couple of extra things:
A camera zoom and focus on the enemy on target.
A break of the targeting mode when the player backs away a certain distance.