Skip to main content

Day 3: Z-Targeting (Lock On Targeting)

Welcome back to another deep dive into Wind Waker.

Investigating source material:

I am going to be implementing the Z-Targeting(Lock-On) mechanic. First I need to study and experiment with Wind Waker and break apart the mechanic.

Here is some terminology I am going to use through out the post and in the provided code.

Seeked = Target that has been found
Locked = Player is locked onto the Seeked by holding down ZL
EmptyLock = Press and holding down ZL with nothing Seeked

From playing Wind Waker these things were witnessed:
  • Only one target can be Seeked or Locked at a time.
  • Only a new target is Seeked once the player is no longer in range or within facing threshold of the current Seeked
  • The closer target will get priority to be Seeked if there are two or more Seeked within range and within facing threshold
  • To Seek an target you must be within its interaction distance. Each intractable object has a max distance that it can stay locked.
  • How direct the camera needs to be facing the target to Seek it varies
  • The camera pivot point is between the target and the player when Locked. Pivot works along with the rotation of the camera to keep the target and player in view
  • When Locking/EmptyLock the camera will adjust to face the direction of the player is facing.
  • Targets can be Seeked when EmptyLocked.
  • When leaving Locked or EmptyLocked the camera zooms out and in based on the character distance and rotates based on the side to side movement. This functionality is drop if at any point the player moves the camera after or during Locking.
  • When Locked, the camera will rotate to the side to view the target and rotate with the player if outside of its allowed angle.

Locked Reference



Seeking Reference

Keeping Both In View

EmptyLocking and strafing

Implementing Z-Targeting:

I added in the system that would Seek out targets and handle the Locking mechanic. The use of a simple mesh color change is for debugging purposes. This target in the example had a strong requirement to be looking directly at it.

Seeking a target

I added Locking onto the Seeked target. The camera will look at a point between the target and the player. It also shifts the pivot of the camera out towards the target based on camera rotation around the pivot.

Locking onto a target


I implemented an priority system considering distance and facing direction of the player

Weighted system based on character facing and distance

I implemented a strafe when the player doesn't have a target Seeked when hitting ZL. Also it goes into a auto zoom and rotate when the player leaves targeting and last until the user moves the camera. It zooms out as the player moves away from camera and zooms in when the user approaches the camera. It also rotates to keep the player centered.

Strafing and camera zoom

Post Lock without user input

Finally, we add in a tracker when the user isn't controlling the camera to keep sure the player and the target stay in frame. This includes moving to the side if the player's character is blocking the view of the target.

Keeping sure both player and target stay in frame

With the use of Scriptable Objects to save data for the camera, player and the target's information, I was able to change values during gameplay until it felt right. As I development more of the systems these values will be revisited and changed.

The next step will be testing it more with uneven ground and moving targets. Then after that we can start adding in character movement controls like rolling and change of speed based on interactions.