简体   繁体   English

Box2d-绳索和距离关节特征之间的折衷

[英]Box2d - compromise between rope and distance joint features

I am struggling with this issue since few weeks, I am making game using BOX2D physics engine (latest version) where I got crane, I needed rope, so at beginning I used distance joint, with anchor points set between hook of the crane, and its arm, it works quite okay. 几个星期以来,我一直在努力解决这个问题,我使用BOX2D物理引擎(最新版本)制作游戏,在那里我需要起重机,我需要绳索,因此开始时我使用了距离关节,在起重机的吊钩之间设置了锚点,并且它的手臂,效果还不错。

I just draw line between those two anchor points, so it looks like a rope. 我只是在这两个锚点之间画线,所以它看起来像一根绳子。

Distance Joint: 距离关节:

Pros: 优点:

  • Little bit elastic look, looks and behaves more realistic. 有点弹性的外观,外观和行为更逼真。
  • I can modify length of my rope on the runtime. 我可以在运行时修改绳子的长度。

Cons: 缺点:

  • there is a minimal distance, so it often start to behave strange (trying to keep minimal distance) while rope is to long. 有一个最小的距离,因此当绳索很长时,它通常会开始表现出奇怪的行为(试图保持最小的距离)。
    • can lift only light objects 只能举起轻的物体

Rope Joint: 绳接头:

Pros: 优点:

  • can lift any object, no matter how heavy it is 可以举起任何物体,无论它有多重
  • there is no minimal distance, so it does not get crazy trying to keep minimal distance 没有最小距离,因此保持最小距离不会发疯

Cons: 缺点:

  • is not flexible at all, so not really realistic. 根本不灵活,所以不是很现实。

Is there any way to combine them, achieving good result, where: 有什么方法可以将它们结合起来,取得良好的结果,其中:

  • can pick any load (no matter how heavy it is) 可以拾取任何负载(无论它有多重)
  • can adjust elastics slightly to give it more realistic feel 可以稍微调整松紧带,使其更真实
  • no minimal distance 没有最小距离

Thanks in advance for any help. 在此先感谢您的帮助。

What is the rope joint connected to at the top? 顶部的绳索接头连接到什么位置? Maybe you could make the top body a little bit moveable eg. 也许您可以使顶部主体移动一些,例如。 make it dynamic, and connect it to a static body with a soft joint like a weld joint (and probably another rope joint to stop it moving too far). 使其动态,然后通过软接头(如焊接接头)将其连接到静态物体(可能还有另一个绳索接头以阻止其移动太远)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM