![]() |
Help (Solved)When a rigidbody with a rope attached is deleted, the rope attaches elsewhere - 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 (Solved)When a rigidbody with a rope attached is deleted, the rope attaches elsewhere (/thread-3521.html) |
(Solved)When a rigidbody with a rope attached is deleted, the rope attaches elsewhere - Hatchling - 12-07-2022 I've encountered an issue with pin constraints that even occurs in the demo samples provided with the asset: When a rigidbody with a rope attached (via a pin constraint) is deleted, the rope will suddenly attach to another rigidbody in the scene. I'm assumed originally that when one actor is deleted, any constraints between them would automatically get deleted as well. This appears to not be the case. Not to matter, it seems relatively simple to fix this: shove some code that destroys the ObiParticleAttachment script when the m_Target it points to gets destroyed. I'm just wondering what you'd recommend to be the best way to handle this. Some ideas I had and the concerns involved with each:
Thanks! ![]() RE: When a rigidbody with a rope attached is deleted, the rope attaches elsewhere - josemendez - 12-07-2022 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) Once integrated in the method, it should look like this: Code: if (enabled && m_Actor.isLoaded && isBound) Let me know how it goes, don't hesitate to get back in touch if you need any help. cheers! RE: When a rigidbody with a rope attached is deleted, the rope attaches elsewhere - Hatchling - 14-07-2022 (12-07-2022, 07:35 AM)josemendez Wrote: Works perfectly. Much less code than the stuff I put in. Thanks! ![]() |