Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  (Solved)When a rigidbody with a rope attached is deleted, the rope attaches elsewhere
#2
Hi there,

Thanks for reporting this! On paper, ObiParticleAttachments are already handling the case where targets become inactive or are destroyed. This is done in the UpdateAttachment method of ObiParticleAttachment.cs, which is called at the start of every step to check if there's been changes that would require updating constraints. This avoids having to explicitly keep track of all attachments that may affect any given collider.

However there's a bug (I believe a regression from 5.X) that overlooks the case where the target is destroyed instead of deactivated: the isBound variable returns false -since there's no longer any target to be bound to- and the pin constraints are not flagged dirty. Just add this else clause at the very end of the method:

Code:
else if (!isBound && attachedColliderHandleIndex >= 0)
{
     attachedColliderHandleIndex = -1;
     m_Actor.SetConstraintsDirty(Oni.ConstraintType.Pin);
}

Once integrated in the method, it should look like this:

Code:
if (enabled && m_Actor.isLoaded && isBound)
{
//....
// all existing code for static/dynamic attachments here
//....
}
else if (!isBound && attachedColliderHandleIndex >= 0) //<--new code
{
     attachedColliderHandleIndex = -1;
     m_Actor.SetConstraintsDirty(Oni.ConstraintType.Pin);
}

Let me know how it goes, don't hesitate to get back in touch if you need any help. cheers!
Reply


Messages In This Thread
RE: When a rigidbody with a rope attached is deleted, the rope attaches elsewhere - by josemendez - 12-07-2022, 07:35 AM