swift usesPreciseCollisionDetection 不起作用?

标签 swift sprite-kit detection skphysicsbody

我做了一个应用程序,你需要向敌人射击,但有时子弹会穿过敌人。 swift sprite kit game when I shoot on a enemy sometimes the bullet goes trough the enemy, how can I fix this?

所以我添加了 usesPreciseCollisionDetection = true。 但子弹有时仍会穿过敌人。所以我的问题是我做错了什么还是 usesPreciseCollisionDetection 不起作用?

感谢您阅读我的问题我希望有人能帮助我。

最佳答案

您正在使用 moveTo 移动子弹,物理引擎无法按照您希望的方式使用 moveTousesPreciseCollisionDetection 不会做任何事

就您的物理世界而言,您的子弹是静止的。你只是在扮演上帝并进行某种分子运输来移动元素。

您需要使用像 applyImpulse 这样的函数,如果您想让它正常工作,甚至只需要给 physicsBody 一个速度

关于swift usesPreciseCollisionDetection 不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39104470/

相关文章:

swift - WorldNode 与对象生成冲突

swift - 更改 GameViewController 中必须首先执行的场景后出错

ios - 检测 iPhone 中的 GPS 硬件

android - Android和IOS上的SDK检测

c - 如何从 Swift 调用 dispatch_benchmark

swift - 根据注释的属性设置注释的字形文本

ios - 比特币 : GoogleMaps framework not found issue

ios - 我不断收到使用未解析的标识符错误

ios - Spritekit 和 swift - 如何在测试期间从测试人员那里取回数据

opencv - 使用 opencv 和 python 检测瓶子上的盖子