Obi Official Forum
Remove / add particle attachment at runtime? - 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: Remove / add particle attachment at runtime? (/thread-2391.html)



Remove / add particle attachment at runtime? - Lockpickle - 29-07-2020

Hi, I'd be interested in removing or adding particle attachments from ropes at runtime. Is this possible? Or could this be done by adding a rigidbody and a normal Unity joint to use as a proxy?


RE: Remove / add particle attachment at runtime? - josemendez - 31-07-2020

(29-07-2020, 03:06 PM)Lockpickle Wrote: Hi, I'd be interested in removing or adding particle attachments from ropes at runtime. Is this possible? Or could this be done by adding a rigidbody and a normal Unity joint to use as a proxy?

Sure, simply add a ObiParticleAttachment component as you would with any other component, and set its target and particle group attributes to whatever you need. To remove it simply destroy the component.

let me know if you need help with this.


RE: Remove / add particle attachment at runtime? - Lockpickle - 31-07-2020

(31-07-2020, 12:23 PM)josemendez Wrote: Sure, simply add a ObiParticleAttachment component as you would with any other component, and set its target and particle group attributes to whatever you need. To remove it simply destroy the component.

let me know if you need help with this.

Thanks! This didn't seem to work when I tried it, but maybe I had something wrong. I did get it working eventually using a proxy object. But also, what if I want to attach something to a part of the rope other than a control point, can I somehow add a particle group dynamically?


RE: Remove / add particle attachment at runtime? - josemendez - 31-07-2020

(31-07-2020, 04:05 PM)Lockpickle Wrote: Thanks! This didn't seem to work when I tried it, but maybe I had something wrong. I did get it working eventually using a proxy object. But also, what if I want to attach something to a part of the rope other than a control point, can I somehow add a particle group dynamically?

Yes, a particle group is simply a scriptable object that contains a list of particle indices. You can create one (using CreateInstance, the usual way for scriptable objects) and populate its particleIndices list with the indices of the particles you want to attach. Then, assign it to the attachment.