统一 - 根据物理形状检测特定瓷砖的碰撞

发布于 2025-02-03 21:37:49 字数 340 浏览 3 评论 0原文

我已经设置了游戏来检测与TileMapCollider2D的碰撞。我所有的瓷砖都有自己的自定义物理形状(半细胞,三角形等),到目前为止,该部分有效。

现在,我想有能力不仅检测出碰撞,还可以检测到碰撞的瓷砖。我能够找到的大多数解决方案都涉及通过tilemap.worldtocell(worldpos)找到碰撞的单元格坐标,这将与方形瓷砖一起使用。但是,由于我的物理形状非常不规则(有时比单个细胞大得多),因此我需要可以根据物理形状本身检测到的东西,而瓷砖被击中。

如果使用TileMapCollider2D无法做到这一点,那么我可能必须使用多个墙面找到解决方案。关于完成我想要的最佳方法的任何想法吗?提前致谢!

I have my game set up to detect collisions with a TilemapCollider2D. All of my tiles have their own custom physics shapes (half cells, triangles, etc.), and so far this part works.

Now, I want to have the ability to not only detect a collision, but also detect which tile that collision was with. Most solutions I've been able to find involve finding the cell coordinates of the collision, through tileMap.WorldToCell(worldPos), which would work great with square tiles. However, since my physics shapes are VERY irregular (sometimes much larger than a single cell), I need something that can detect based on the physics shape itself which tile was hit.

If this isn't possible with the TilemapCollider2D then I may have to find a solution using multiple colliders. Any idea of the best way to accomplish what I'm looking for? Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文