Obi Official Forum
Help Particle Attachment Break - 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 Particle Attachment Break (/thread-2199.html)



Particle Attachment Break - Kristaps - 26-04-2020

Hello!

Is there are a way to get a callback when Particle Attachment breaks?
Huh
Found only that Tearing has a callback.


RE: Particle Attachment Break - josemendez - 28-04-2020

(26-04-2020, 02:50 PM)Kristaps Wrote: Hello!

Is there are a way to get a callback when Particle Attachment breaks?
Huh
Found only that Tearing has a callback.

Hi there,

Not by default, attachments (unlike tearing) are much easier to react upon by simply checking the distance of their particle group to the target position.

If you really need a callback, it's pretty easy to add though: in ObiPinConstraintsBatch.cs file, the last method is called BreakConstraints(). This is called from the attachment every frame, it iterates over all pin constraints to check if any of them is over the break threshold. If so, it deactivates the constraint (line 117 in the file).

Simply call a custom C#/Unity event from there.


RE: Particle Attachment Break - Kristaps - 28-04-2020

(28-04-2020, 08:16 AM)josemendez Wrote: Hi there,

Not by default, attachments (unlike tearing) are much easier to react upon by simply checking the distance of their particle group to the target position.

If you really need a callback, it's pretty easy to add though: in ObiPinConstraintsBatch.cs file, the last method is called BreakConstraints(). This is called from the attachment every frame,  it iterates over all pin constraints to check if any of them is over the break threshold. If so, it deactivates the constraint (line 117 in the file).

Simply call a custom C#/Unity event from there.

Yep, after digging trough, the code thought of the same approach!
Sonrisa

Thanks!