没有 AABB 的游戏的 2D 碰撞
检测 2d 游戏碰撞的最佳方法到底是什么?我使用 aabb(轴对齐边界框),但如果你有一个大圆圈或其他东西,当你距离它大约 200 像素时,你就会碰到它。最好的方法是只查看两张图像中的像素是否接触?请告诉我一个好的方法。
编辑: 好吧,现在我意识到圆形碰撞是多么简单。但假设我有一个椭圆形或不是真正形状的东西。或者甚至是旋转 45 度的正方形。
What exactly is the best way to detect 2d game collision? I use aabb's (axis-aligned-bounding-boxes) but if you have a big circle or something, you will be hitting it when your like 200 pixels away. Would the best way be to just see if the pixels in the 2 images are touching? please let me know a good method.
EDIT:
Ok so now I realize how simple circle collision is. but say I have an oval or something that isn't really a shape. Or even a square that is rotated 45 degrees.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果你有圆圈,你可以使用圆到圆的碰撞。只需获取中点的距离并将其与半径的长度进行比较即可。
除此之外,这实际上取决于您的需要。有大量的碰撞检测算法(主要是为了加快速度,例如通过使用帧之间的一致性),但这超出了简短的一般说明的范围,您需要更多地指定您的问题。
If you have circles you can use Circle-To-Circle collision. Just take the distance of the midpoints and compare it with the length of the radii.
Beside that it really depends on what you need. There's a plethora of collision detection algorithms (mostly to speed things up, e.g. by using coherence between frames) but that's out of the range for a short general note and you'd need to specify your problem a bit more.