Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Unpin Rope not working
#1
Hi, 
I've attached pin at both end of the rope. I want to unpin it from one of the ends.
I've tried the below code but nothing seems to be working. Its always pinned even after running the below code.
I've attached reference screenshot of what I am trying to do. 
Created 2 ropes and pinned them on the board. I want to unpin one end of the rope and pull the rope to the other knob using obiropecursor. (ChangeLength function).
Using ObiRopeCursor is the right approach here ?

Code:
var pinConstraints = rope.GetConstraintsByType(Oni.ConstraintType.Pin) as ObiConstraints<ObiPinConstraintsBatch>;
int batches = pinConstraints.batches.Count;
for (int j = 0; j < batches; j++)
{
    int count = pinConstraints.batches[j].constraintCount;
    Debug.Log("count : " + count);
    for (int i = 0; i < count; i++)
    {
        pinConstraints.batches[j].RemoveConstraint(i);
        pinConstraints.batches[j].RemoveFromSolver(null);
    }
    pinConstraints.RemoveBatch(pinConstraints.batches[j]);           
}
pinConstraints.RemoveFromSolver();

To test if cursor changeLength is working I manually disabled one of the pinned gameobject and tried the below code. ChangeLength function is also not working as expected.
Its pulling the rope only to some extent. After that rope got stiff and straightened. Attached screenshot.

Code:
private void Update()
  {
      if (knobDetached)
      {
          cursor.ChangeLength(rope.restLength - 30 * Time.deltaTime);
      }
  }

Note:
If I use ObiParticleAttachment instead of Pin Constraint, cursor changeLength is working as expected

Code:
private void RopeAttachment(ObiRope rope, ObiCollider bodyA, ObiCollider bodyB)
{
    attachment1 = rope.AddComponent<ObiParticleAttachment>();
    attachment1.target = bodyA.transform;
    attachment1.particleGroup = rope.blueprint.groups[0];
    attachment1.attachmentType = ObiParticleAttachment.AttachmentType.Dynamic;

    attachment2 = rope.AddComponent<ObiParticleAttachment>();
    attachment2.target = bodyB.transform;
    attachment2.particleGroup = rope.blueprint.groups[rope.blueprint.groups.Count - 1];
    attachment2.attachmentType = ObiParticleAttachment.AttachmentType.Dynamic;
}


Attached Files Thumbnail(s)
       
Reply


Messages In This Thread
Unpin Rope not working - by kripa1415 - 05-06-2024, 08:27 AM
RE: Unpin Rope not working - by josemendez - 05-06-2024, 10:48 AM
RE: Unpin Rope not working - by kripa1415 - 05-06-2024, 02:12 PM