什么是在Unity 2D中设计方向性后坐力的最佳方法?

huangapple go评论63阅读模式
英文:

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:

https://gdl.space/itiyazuwet.cs

答案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!

huangapple
  • 本文由 发表于 2023年7月27日 22:39:23
  • 转载请务必保留本文链接:https://go.coder-hub.com/76780855.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定