Camera lockOn view blocking


Reported by: Eldar Bertsel

October 19, 2023

THE PROBLEM

One of the problems that I had to deal with was related to the lock on view blocking mechanic that I had implemented. Basically, it is a mechanic that checks whether there is anything like a wall between the player and an enemy. If there is then the lock on should turn off because it doesn't make sense to be locked on to someone who you can't even see. The way that mechanic worked is it would create a ray from the player to the target that the player is locked on, check its tag, and if there is something in between them at any point, meaning something that has not an enemy tag, then the lock on would turn off.  Unfortunately, some of the abilities that I have like fireball or a fire blast would block the view with their colliders. Even though you can't see the colliders they are still there and the ray can hit them, so every time the player or an enemy like magician would cast those abilities then the lock on would turn off. 


THE SOLUTION

The solution to it was quite easy. I decided to make a check that would only check for objects with a stationary tag and if it hits that check then it would start a 3 seconds timer. if during those 3 seconds the ray was still colliding with a stationary object then it turn the lock off otherwise the lock will say on. This not only fix my issue but also makes the process of locking on and off smoother because the lock on isn't turn of instantly if there is something between the player and a locked on target. 

Get Psyche

Leave a comment

Log in with itch.io to leave a comment.