如何在 Box2D 中攀爬或粘住其他物体?
我知道尝试在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
关于小跳跃,您可以通过使用碰撞组来避免多个对象的奇怪结果。您仅计算属于特定组的对象的对象法线和后续跳跃。
告诉我您是否需要帮助设置这些冲突组,尽管我不熟悉闪存端口。
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.