Help Deleting particles when in contact with certain objects - Printable Version +- Obi Official Forum (https://obi.virtualmethodstudio.com/forum) +-- Forum: Obi Users Category (https://obi.virtualmethodstudio.com/forum/forum-1.html) +--- Forum: Obi Fluid (https://obi.virtualmethodstudio.com/forum/forum-3.html) +--- Thread: Help Deleting particles when in contact with certain objects (/thread-3360.html) |
Deleting particles when in contact with certain objects - fanoftoucans - 14-03-2022 Hello! Context: I am relatively new to unity and very new to Obi Fluids. I am working on a VR project where I have an emitter for a sink that turns on if the player holds a cup under the sink. This part works fine, but because I want the particles to stay in the cup, I have set the lifespan to "infinity" for my sink emitter. This works fine when the water is in the cup, but because movement is very jumpy/sudden in VR, sometimes the particles will fly out of the cup and into the sink / on the floor. Question: Is there a way to make it so particles are killed (lifespan set to 0) if they touch the sink or floor (or any specific object) and still have an infinite life in the cup? The goal is to have an infinite life for the particles only while in the cup, and if the particles hit the sink or floor they are sent back to the emitter. This would mean I could theoretically fill up my cup, dump it down the sink and see the particles "drain", and fill my cup at the sink again. Let me know if I can clarify anything. As mentioned, I'm relatively new to this, so I don't have any foundation work for this goal; I'm starting from scratch. I mostly want to know if it's possible and what I would need to do to make this happen (e.g. call a system or built in function that I am unaware of.) Thanks! RE: Deleting particles when in contact with certain objects - josemendez - 14-03-2022 Hi there! You want to use collision callbacks: http://obi.virtualmethodstudio.com/manual/6.3/scriptingcollisions.html Then, just set the lifetime of the particles in contact with your collider to zero. Like this: Code: int particleIndex = solver.simplices[contact.bodyA]; The manual includes sample code snippets to iterate trough all contacts and determine particles in contact with a given collider, as well as killing a certain particle in a emitter - like above. let me know if you need further help, kind regards RE: Deleting particles when in contact with certain objects - fanoftoucans - 14-03-2022 That seems to be working great, Thanks for the help! |