as3:Box2d如何找到最近的尸体
如何找到位于给定尸体附近的尸体。
关于任务。我正在尝试检测接近当前的尸体。为此,我在当前主体周围创建了一个相当大的碰撞形状,并将其设置为传感器。碰撞事件被触发,但这不是我需要的。最主要的是,仅当另一个物体进入检测场时才第一次调用碰撞事件......并且我希望能够检测到之后物体位置的变化。 (我正在考虑其他物体正在检测范围内移动的事实)
How do I find bodies which are located near given body.
About the task. I am trying to detect bodies which are near current. To do it, I've created quite a big collision shape, around the current body, and made it sensor. Collision event was triggered, but it's not what I need. Main thing is that collision event is called only first time when another body entered the detection field... And I want to be able to detect changes in bodies location, after it. (I am considering the fact that other bodies are moving inside detection field)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为什么不通过将主体存储在集合中来跟踪碰撞呢?在 EndContact 上,您可以从集合中删除所述主体。
至于跟踪该检测区域内的尸体,您可以循环遍历该集合并检查位置。
或者,如果精度不是一个大问题,可以创建几个传感器主体,每个传感器主体的半径都比最后一个更小,然后您可以检测它所在的区域。
Why not just keep track of collision by storing the bodies in a collection? On a EndContact you can remove said body from the collection.
As for tracking the bodies inside this detection field, you could loop through this collection and check the positions.
Alternavily, if accuracy was not a huge concern, create a few sensor bodies, each with a smaller radius that the last and then you can detect which zone it is in.