- Home /
Target the most centered Object
Hello, I have an issue: After triggered an action, I would like to get the target of the most centered enemy. My problem is that raycast will be valid only if I point the enemy at least once, but still need a visual check of the target so cant use area of collision. Let's suppose, I have the enemy in my camera, but I am slightly rotated to the ground and with the press of a button I want to target that enemy. I could put the raycast on a parent of the camera so that will not be influenced by the camera rotation, but if there will be more than 1 enemy how can I lock the most centered one?,
Answer by logicandchaos · Aug 20, 2021 at 04:50 PM
Have a center point, defined as a transform, from that point find the closest points among enemies using Vector3.Distance();