Obi Official Forum
Help When adding rope, the new rope section gets "stuck" and behaves strangely - Printable Version

+- Obi Official Forum (https://obi.virtualmethodstudio.com/forum)
+-- Forum: Obi Users Category (https://obi.virtualmethodstudio.com/forum/forum-1.html)
+--- Forum: Obi Rope (https://obi.virtualmethodstudio.com/forum/forum-4.html)
+--- Thread: Help When adding rope, the new rope section gets "stuck" and behaves strangely (/thread-3978.html)



When adding rope, the new rope section gets "stuck" and behaves strangely - ShawnF - 22-08-2023

So there's an action in my prototype that will cause a rope to lengthen so that it's usable. When this is done, I'm seeing two problems:

1) The rope gets a bit longer, but not as long as defined... until you jump on it, at which point it sort of gets "unstuck".

2) The rope doesn't seem to be simulated correctly until it gets "unstuck". This doesn't actually hurt my use case, but I thought it might be a hint about what's going on.

Here's the code I'm using for testing:
Code:
void Update()
    {
        if (Input.GetKeyDown(KeyCode.F12) )
        {
            resizeRope = true;
            MainCanvasScript.instance.ShowQuickInfoMessage("Start Rope Resize", 1f);
           
            //cursor.sourceMu = 1f;  // default 0
            cursor.cursorMu = 1f;  // default 0;  start adding rope at the end
            cursor.direction = false;  // default true;  don't understand why, but no visible rope spools out if this is true
        }
    }

    void FixedUpdate()
    {
        if (resizeRope && obiRope.restLength < resizedLength)
        {
            cursor.ChangeLength(obiRope.restLength + lengthAddedPerStep);
            Debug.Log(obiRope.restLength);
        }

        if (resizeRope && obiRope.restLength >= resizedLength)
        {
            resizeRope = false;
            MainCanvasScript.instance.ShowQuickInfoMessage("resize complete", 3f);
        }
    }

Here's a video showing the behavior that I'm talking about. You can see how the rope is using physics before it's resized, but stops reacting after the new section is added... until I jump on it and start swinging.
https://www.youtube.com/watch?v=tp34KpfQ1Ak


I can also post my janky WIP code for how the player attaches/climbs if it's useful, but I'm leaving it out for now because it's a bit long. Basically it's just moving the character to the next particle index and creating a particle group / attachment at that particle.


RE: When adding rope, the new rope section gets "stuck" and behaves strangely - josemendez - 22-08-2023

Hi,

The cursor’s “source mu” is set to zero, so it’s using the first particle in the rope as a source to create new particles in the rope. My guess is that your rope’s first particle has infinte mass since it’s attached (that’s how particles are attached) so the newly instantiated particles also have infinite mass and are also attached.

As your character climbs up the rope removing attachments, it resets their mass, deattaching them.

Just use an appropriate value for “source mu”, one that picks particles from mid-rope for instance.

Kind regards,


RE: When adding rope, the new rope section gets "stuck" and behaves strangely - ShawnF - 23-08-2023

Thanks, that was really helpful! I thought I had tried that, but apparently not.

This allowed me to get it working for my use case, but I found that the rope gets stuck on itself until it's wiggled a bit, especially if you try to add rope quickly. I just programmatically added a bit of wiggling at the top attachment while the rope is growing, but I'm guessing that there's a better way.

To show you what I mean... If I use my above code, but with sourceMu = 0.5f, here's what I'm getting if I don't add any rope wiggle:
https://youtu.be/UKMcsB3Lkp4

This happens more if I add a lot of rope per step (0.5) vs if I add a smaller amount (0.1), but it always gets stuck at least a bit if there's no wiggle.

Again, I found a workaround so no big deal, but I thought it was worth mentioning in case it's a bug and just so I can undestand the system better.