Im making a 2D roguelike with guns, and I have 4 different recoil animations for when the Shoot method is called: recoilLeft, recoilUp, recoilRight, and recoilDown. I want the respective animation play based on your position to the closest enemy. I have all the other code set up for firing, finding the closest enemy, but im just trying to get the recoil to work right now.
Is this a good way of going about directional recoil? Or is there a better way? Feedback is much appreciated.
Script attached to the gun: