Targeting system

When I’m attacking I attack the current closest enemy but if another one becomes the closest enemy my character ignores the previous one and focuses on the current closest enemy