Radiant Studio
Skip

Devlog #7 – Target Locking

Last session concluded a very important feature for the combat system. The target locking. Target locking is a way to focus the view and movement around an object of interest. This helps a lot during combat. Target locking is implemented in several phases on its own component class.

First when player hits a certain key we will cast a sphere ray with a given radius ( green sphere ). Everything that the sphere hits becomes eligible target for locking. Then we need to find the closes target to the screen and lock on that ( red ray ). After the closest target has been found player movement and camera look are locked to its position.

When shooting the ray there can be a lot of targets that can be hit. This is a costly operation and to optimize it a little we will limit the ray to only look for specific targets that implement given interface. This way the ray will not look for actors that are not of interest to the player or for combat. The special interface is attached to the base enemy class and every enemy that inherits the base enemy class becomes eligible for target locking.