简体   繁体   中英

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)

在此处输入图片说明

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). 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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