Advertisement

Am I putting too much faith in ropes?

Started by March 16, 2024 08:55 PM
4 comments, last by MidLevelGameDev 9 months, 1 week ago

I have been trying to get this rope to work, implemented with an array of spheres, linked with ball-socket joints in Open Dynamics Engine. The goal is for the rope to go around the crevice within the wall, but no matter what configuration I try, it clips through the wall, instead. In the below example, the rope connects the cube to another cube on the other side of the wall.

Thinking about it, I've never seen any other game attempt this kind of mechanic. Am I asking too much out of physics engines for wanting this?

MidLevelGameDev said:
Am I asking too much out of physics engines for wanting this?

Probably. Ropes/chains are generally difficult to get working robustly in basic scenarios, much less something like you are trying to do. It's hard to see exactly what is going on in your screenshots (it's very dark, I can't see the crevice and the rope visualization is hard to interpret).

I guess you are trying to get the rope to follow a complex path through the wall so that pulling on one side pulls the cube on the other side, and that might solve a puzzle or something.

To get that to work robustly you probably want a special case system to handle it that omits/abstracts the part of the rope inside the wall. Basically, you keep track of the rope length on either side, and connect a separate rope to the crevice on either side. If the user pulls on one side, you increase the length on that side and reduce the length (number of links or link spacing) on the other side. You can make the crevice connection point slightly inside the wall (i.e. 1 link worth of distance) to hide the length transitions. This should produce the desired behavior and will be much easier on the physics engine.

You can also try increasing the number of links in the chain. This will make the behavior more “rope like” and less like discrete links, but also will use more CPU, and can become unstable with a large number of links.

If ODE supports it, a “distance” constraint would be better than a ball and socket constraint. That will allow the rope to collapse on itself as it should when there is no tension. Ball and socket would prevent the links from being close together, and will make the rope seem more rigid and unnatural.

Advertisement

I can not see the crevice in the images. It should be large enough so the spheres fit through easily ofc.

Besides, try to keep the mass ratio small. Ideally all bodies have the same mass. This means ‘heavy’ rope segments and ‘lightweight’ boxes, but ideally the cheat is not noticeable to the player.

Minimize the number of rope segments. Eventually use capsules instead spheres, which is still a cheap collision primitive, and makes it easier to slide through the hole.

It might work, but in difficult situations it will jitter badly i guess. ODE is quite old and did not see an update for decades i guess. But it was not bad when i tried it in the year 2000 or so. Such problematic case depends a lot on the physics engine, i'm sure.

Alternatively, you could model the rope with a two max distance constraints: Box → DC → hole in form of a static body → DC → other box. This should work for physics if the engine is flexible enough to implement this, but it woudl not help for a visualization of a rope / chain ofc.

Aressera said:
Basically, you keep track of the rope length on either side, and connect a separate rope to the crevice on either side. If the user pulls on one side, you increase the length on that side and reduce the length (number of links or link spacing) on the other side.

That's what i meant. (Posting at the same time)
Iirc, Newton physics engine has (or had) a ‘pulley' joint for such things. But not sure if that's a common feature. (Newton is very flexible with making custom joints as needed.)

I edited the images to make it clearer.

Those ideas are great and all, but I'm not sure how I'd do that with ODE, considering the cube are meant to be moved around the crevice. ODE isn't unsupported or unmaintained, but documentation is sparse for sure. So, the best approach? Just lower the crevice.

This topic is closed to new replies.

Advertisement