Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Rope cursor jittering from strange spot
#1
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.
Reply


Messages In This Thread
Rope cursor jittering from strange spot - by alehrecke - 09-04-2021, 03:41 PM