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:
your approach seems to be pretty reasonable and I believe it's going to work as expected.
I have done something similar to this once and I can assure you that you are definitely on the right track!
Good job buddy!