Hey, so I want to make a system where you lock onto the enemy closest to a reticle.
I was watching a tutorial on how to make a lock on system here: UE4 Improved Camera Lock-On Tutorial Part 2 | Unreal Engine 4.16.1 - YouTube
And in the last section at 54:51, he explains how to set it up so it’ll lock onto the enemy closest to the center, which I followed. However, I want to go beyond this and lock onto the closest enemy to the reticle widget, which has been a struggle for me.
I already have it set up so that the reticle is movable when I push a certain button and will freeze if I hit it again, and another button that will automatically center the reticle in either state, the problem is that I can’t figure out how to get the reticle to tell which enemy is closest to the reticle on the screen within the range.
These are the variables I’m using(X & Y Canvas are the reticle’s location):
I’ve tried using X & Y canvas on a bunch of different switches for the canvas location and messing around with the math, but nothing seems to be working
I feel like the answer is somewhere around here, but I just can’t find it.
Any help would be much appreciated,
Thank you.