Attack by direction

Would anyone know how to make the player character pick a different animation based on where the nearest enemy is? Similar to how GTA characters stomp characters on the ground or elbow characters standing behind them