Tshmofen/verlet-rope-4

Rope does not pull Rigidbodies

Xacorman opened this issue · 2 comments

I see the .gif on the main page but am unable to replicate. I have two rigidbodies with a Verlet Rope node added as a child of one and connected to the other. Pulling one rigidbody just stretches the rope rather than pulling the other rigidbody once it reaches max length.

Hi! I guess I will add the additional description to cover your case, the gif I've provided is not just VerletRope node, the addon only provides visuals of the rope - it's does not affect other bodies just like that.

To achieve the same effect as I did, you will have to add a suitable Joint between two bodies, that will give two bodies a max distance between them. When I did that recording Jolt didn't have any kind of distance joint (and I don't think it they have it now, though the default Godot may), so I emulated it by using GeneralJoint with restriction on distance (don't remember exact settings, so you will have to play with it around to figure out best approach). And to make it behave as true distance joint I've just always placed it between two bodies like that:

/// <summary>
/// Temporary replacement for not yet supported distance joint.
/// Should be attached to a GeneralJoint to be between both objects.
/// </summary>
[GlobalClass]
public partial class DistanceJoint : Node3D
{
    [Export] public RigidBody3D BodyA { get; set; }
    [Export] public RigidBody3D BodyB { get; set; }

    public override void _Process(double delta)
    {
        var a = BodyA.GlobalPosition;
        var b = BodyB.GlobalPosition;
        GlobalPosition = a + (b - a)/2f;
    }
}

If you go with default physics, you can replace Node3D with the actual joint (or in that case you may not need that custom joint at all - leaving the investigation to you). Hope it helps :)

I appreciate the response. Making your code above extend Generic6DOFJoint3D did the trick.