如何在 Box2D 中攀爬或粘住其他物体?

发布于 2024-12-26 06:18:24 字数 309 浏览 0 评论 0原文

我知道尝试在 Box2D 中模拟角色运动总是很困难/不可能,但我试图看看是否有任何方法可以制作一个用户控制的对象,可以干净地相对于其他对象向上或向下滑动,从而使其看起来就像角色正在攀爬/向上或向下行走。

如果可以简化问题,可以将角色建模为圆形,但我不知道如何仅使用带有关节电机的圆形来获得这种效果。 Box2d 的 C++ 版本中有一个“轮子接头”,我想我可以将其移植到 Flash,但我也不知道这是否会产生正确的效果。

我的另一个想法是让角色根据它所接触的物体的法线进行小跳跃。但我怀疑在角落或与多个物体接触时,这会产生奇怪的结果。

有什么想法吗?多谢。

I know that trying to model character movement in Box2D is always hard/impossible, but I'm trying to see if there's any way to make an user-controlled object that cleanly slides against other objects, going up or down, that makes it look like the character is climbing/walking up or a down.

The character could be modelled as a circle if that simplifies matters, but I don't see how I could get this effect using just a circle with a joint motor. There's a "wheel joint" in the C++ version of Box2d, which I suppose I could port to Flash, but I don't know if that would give the correct effect either.

Another idea I had was to have the character do little jumps, based on the normal of the object that it is touching. But I suspect that at corners, or at contacts with multiple objects, this will give weird results.

Any ideas? Thanks a lot.

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

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

发布评论

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

评论(1

源来凯始玺欢你 2025-01-02 06:18:24

关于小跳跃,您可以通过使用碰撞组来避免多个对象的奇怪结果。您仅计算属于特定组的对象的对象法线和后续跳跃。

告诉我您是否需要帮助设置这些冲突组,尽管我不熟悉闪存端口。

Regarding the little jumps, you can avoid the weird results with multiple objects by using collision groups. You only calculate the normal of the object, and subsequent jump, on objects which belong to a certain group.

Tell me if you need help setting these collision groups, though I'm not familiar with the flash port.

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