I'm wanting to create a rope that can collide with objects like in the following youtube video:
I'm thinking that you implement the verlet integration which uses points and connects these points with lines. I'm trying to figure out what type of collision detection you would apply to the rope to get the effect in the video.
I'm thinking you would have to do some cd to each point. I would like to use box2D, so I'm wondering would making each point a rigid body work? Any advice would be appreciated.
Answer
Since you're using Box2D, you can create a series of rectangles and use Box2D's joints to join them. There you have your rope.
In order to avoid corners poking out of a bent rope, I can imagine two options:
- Give your rope segments rounded ends (so they won't be rectangles anymore)
- Make this rope itself invisible and use it only for physics. Take the positions of the joints in each frame and use that to draw a rope on the fly that the player will see.
Warning: I have never tried this myself, but I fail to see how a series of joined rectangles can fail when the video you posted displays practically the same thing in disguise.
Edit: I just saw PaulZ and I realised the same thing. Go read his comment on the question as well.
No comments:
Post a Comment