I agree with Nick. If you are using a collision sphere (not trace) you can simply use overlaps. When a target overlaps the collision sphere, add them to an array and when you right click to aim you iterate that array to see which is the closest target either by distance and/or angle (you don’t want to snap around backwards if that’s the closest target.) When a target is destroyed or it leaves the collision sphere (End Overlap) you remove it from that array. For Get Distance To ‘Target’ would be your target but Other Actor would be ‘Self’ as the character. Put that value into a local float , and run a check to see if the current value is less than the value in the float. If it is, add that Target to your target variable if not do nothing. At the end you will have you closest target by distance. But you’ll probably want to formulate an angle check in here as well.
You can also run the sphere trace on each click rather than the overlap. Traces are a relatively cheap operation. No need for Get All Actors with the trace. You only get one result with a trace which should be the first target it hits (the closest) but again this won’t care if it’s behind you causing you to snap around which may look unnatural.