How do I auto-aim?

I’m working on a 2D platform game project, where my main character uses a bow that shoots “magic” arrows, hence I thought of implementing in my game the self-aiming system of “Ori and the blind forest”, when a key is pressed the arrows will go direct to the nearest enemy located a certain distance as in the game of Ori, but I’m kind of lost, could you help me?

Try the game lookAt method