Setting up a targeting system

so I made a teleportation system for my player and I want the crosshair to be able to detect enemies or an edge of a surface and auto target it when the crosshair is near it, so the player could effectively and easily teleport to the assigned target, any ideas?