![]() |
Help Cloth collision actors - Printable Version +- Obi Official Forum (https://obi.virtualmethodstudio.com/forum) +-- Forum: Obi Users Category (https://obi.virtualmethodstudio.com/forum/forum-1.html) +--- Forum: Obi Cloth (https://obi.virtualmethodstudio.com/forum/forum-2.html) +--- Thread: Help Cloth collision actors (/thread-3939.html) |
Cloth collision actors - domopuff - 15-07-2023 Hello, How can I obtain the actors that have collided with my cloth object? Thanks! Christopher RE: Cloth collision actors - josemendez - 15-07-2023 (15-07-2023, 07:30 AM)domopuff Wrote: Hello, Hi! You can get a list of all particle-particle contacts each frame by subscribing to solver.OnParticleCollision. Then it’s just a matter of retrieving the actor(s) involved in each contact. How to do this is explained in the manual: http://obi.virtualmethodstudio.com/manual/6.3/scriptingcollisions.html Kind regards, RE: Cloth collision actors - domopuff - 15-07-2023 (15-07-2023, 11:03 AM)josemendez Wrote: Hi! Thanks for the reply! I managed to get the collisions detection working but performance did take a heavy hit. Any way we can try get the center points of a cloth instead? RE: Cloth collision actors - josemendez - 17-07-2023 (15-07-2023, 02:55 PM)domopuff Wrote: Thanks for the reply! I managed to get the collisions detection working but performance did take a heavy hit. If you iterate trough all contacts in the main thread using a simple for loop and there's many contacts in your scene, performance will of course be less than good. Try doing this using jobs instead. (15-07-2023, 02:55 PM)domopuff Wrote: Any way we can try get the center points of a cloth instead? Sure, iterate trough all particles in the cloth and calculate their center of mass. There's a snippet in the manual that does just this, pasting it here for convenience: http://obi.virtualmethodstudio.com/manual/6.3/scriptingparticles.html Code: using UnityEngine; Again, doing this in the main thread using a for loop will be slow. Note you can directly use Obi solver arrays in a job, see the "Using Jobs to process particles" section at the end of the page linked above. kind regards, RE: Cloth collision actors - domopuff - 19-07-2023 Thanks for your help. Managed to figure it out! |