简体   繁体   English

Box2d绳索-不固定长度

[英]Box2d rope - NOT fixed length

I am creating game with box2d physics, I have a crane with rope attached to it, something like that (example) 我正在使用box2d物理来创建游戏,我有一个起重机,上面附有绳子,类似这样(示例)

在此处输入图片说明

What I am trying to achieve is to let player to fold or unfold line (to certain limits obviously) currently I am only able to create fixed length rope, which is limiting my game a little bit. 我要实现的目的是让玩家折叠或展开线(显然达到某些限制),我现在只能创建固定长度的绳索,这在一定程度上限制了我的游戏。

How could I achieve it? 我该如何实现? I had couple of ideas, but are rather not good ones, like recreating rope all the time, but it would just destroy my performance. 我有几个主意,但不是好主意,就像一直在重提绳索,但这只会破坏我的表现。

First, I would check to see if that actually does ruin your performance. 首先,我将检查是否确实破坏了您的表现。 You might be surprised by how fast it is. 您可能会对它的速度感到惊讶。

If it does, one solution is to create an array of short ropes attached to one another (say 10). 如果是这样,一种解决方案是创建一系列彼此连接的短绳(例如10)。 This ia basically what a rope is anyway, you just need to hold on to the elements. 基本上这就是一条绳索,您只需要抓住这些元素即可。

To make the rope be 6 units long, hide and collision disable the last 4 and attach the load to the end of the sixth rope segment. 要使绳索长6根,隐藏和碰撞后4根绳索将其禁用,然后将负载附加到第六根绳索的末端。

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

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