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 ?
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.
Note:
If I use ObiParticleAttachment instead of Pin Constraint, cursor changeLength is working as expected
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;
}