英文:
What is an optimal way to design directional recoil in unity 2D?
问题
我正在制作一款带有枪支的2D地牢游戏,当调用Shoot方法时,我有4种不同的后坐力动画:recoilLeft(左后坐力)、recoilUp(上后坐力)、recoilRight(右后坐力)和recoilDown(下后坐力)。我想根据你距离最近的敌人的位置播放相应的动画。我已经设置好了所有其他的射击和寻找最近敌人的代码,但现在我只是想让后坐力正常工作。
这是处理方向后坐力的好方法吗?还是有更好的方法?非常感谢您的反馈。
附在枪上的脚本:
英文:
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:
答案1
得分: 1
你的方法看起来相当合理,我相信它会按预期工作。
我曾经做过类似的事情,我可以向你保证,你绝对走在正确的道路上!
干得好,伙计!
英文:
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!
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论