as3:Box2d如何找到最近的尸体

发布于 2024-10-15 18:46:43 字数 183 浏览 2 评论 0原文

如何找到位于给定尸体附近的尸体。

关于任务。我正在尝试检测接近当前的尸体。为此,我在当前主体周围创建了一个相当大的碰撞形状,并将其设置为传感器。碰撞事件被触发,但这不是我需要的。最主要的是,仅当另一个物体进入检测场时才第一次调用碰撞事件......并且我希望能够检测到之后物体位置的变化。 (我正在考虑其他物体正在检测范围内移动的事实)

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

旧故 2024-10-22 18:46:43

为什么不通过将主体存储在集合中来跟踪碰撞呢?在 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文