In the ‘Improved Targeting Selection’ lecture of the Unity 3rd Person Combat & Traversal:
I’ve found that when the camera faces directly away from a target, it will return a value for viewPos which bypasses the if statement meant to ignore targets that aren’t in the camera’s view:
Vector2 viewPos = mainCamera.WorldToViewportPoint(target.transform.position);
if(viewPos.x < 0 || viewPos.x > 1 || viewPos.y < 0 || viewPos.y > 1) { continue; }
I’m not sure if this is true for everyone or if I’ve changed something somewhere which causes this.