Obi Official Forum
Help Rope cursor jittering from strange spot - 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 Rope cursor jittering from strange spot (/thread-2856.html)



Rope cursor jittering from strange spot - alehrecke - 09-04-2021

Hello,

I am trying to simulate the unrolling of a bobbin when a player moves the "bobbin" that the rope is attached to. I am planning to add more ropes to try and do a braiding simulation. I need each rope to have a cursor so that when they move around one another they wont stretch so much as to pass through one another. 

I have a single rope set up and it is extruding properly in the beginning, but then begins to develop a kink at a spot that makes no sense (it could be the original length of the rope). I have played around with the cursor Mu and it seems to have no effect on this kink. Do you have any suggestions to make this more stable? Right now I am measuring the strain in the rope and if it is above 10% then I run the change length command. Overall, the rope is also quite jittery, which I would also like to try and reduce.

Here is a video of the defect.


And here is my bobbin controller script:
Code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Obi;


public class BobbinController : MonoBehaviour
{
   
    public ObiRope rope;
    public float speed = 1f;
   
    Vector3 velocity;
    Rigidbody rigidBody;
    ObiRopeCursor cursor;

    RuntimeRopeGenerator ropeGen;
    //ObiSolver solver = FindObjectOfType<ObiSolver>();

    float ropeLength;

    // Start is called before the first frame update
    void Start()
    {
        rigidBody = GetComponent<Rigidbody>();
        cursor = rope.GetComponent<ObiRopeCursor>();
        ropeLength = rope.restLength;
    }

    // Update is called once per frame
    void Update()
    {
        Vector3 input = new Vector3(Input.GetAxisRaw("Horizontal"), 0, Input.GetAxisRaw("Vertical"));
        Vector3 direction = input.normalized;
        velocity = direction * speed;

        float currentLength = rope.CalculateLength();
        float restLength = rope.restLength;

        float strain = currentLength/restLength;

        if (strain > 1.1)
        {
            cursor.ChangeLength(rope.restLength + speed * Time.deltaTime);
        }
        else if (strain < 1)
        {
            cursor.ChangeLength(rope.restLength - speed * Time.deltaTime);
        }

       
    }

    private void FixedUpdate()
    {
        rigidBody.position += velocity * Time.deltaTime;
    }

Any help would be greatly appreciated.


RE: Rope cursor jittering from strange spot - josemendez - 12-04-2021

Hi there,

Where's your cursor's "source mu"? This looks like the kinky particle has a really large mass, likely because it's been copied from one of the attached particles. Try using a source of 0.5, so that the new particles are copied from the middle of the rope.

Also, the included util class ObiRopeReel (/Obi/Scripts/RopeAndRod/Utils/ObiRopeReel.cs) looks somewhat similar to what you're attempting to do, it might be helpful. This will change the length of the rope when you stretch it, and attempt to reel back any excess rope so that's always as taut as possible.

let me know how it goes,