Obi Official Forum
Help Retrieving contacts count only from a specific collision - Printable Version

+- Obi Official Forum (https://obi.virtualmethodstudio.com/forum)
+-- Forum: Obi Users Category (https://obi.virtualmethodstudio.com/forum/forum-1.html)
+--- Forum: General (https://obi.virtualmethodstudio.com/forum/forum-5.html)
+--- Thread: Help Retrieving contacts count only from a specific collision (/thread-3020.html)



Retrieving contacts count only from a specific collision - Rearden - 13-07-2021

Hey there! Hope you are all doing well!

I am using Obi fluid. I know that we could receive a contacts count with 
Code:
e.contacts.Count
But it gives all current collision points. My question is there any chance to receive contacts count only for a specific collider? For example, the full count is 1000 and for a collider_1 the count is 300, for a collider_2 the count is 450, etc.

I am interested only in OnCollision event(simplex-collider).

Thank you!


RE: Retrieving contacts count only from a specific collision - josemendez - 14-07-2021

You can count how many contacts reference a specific collider yourself. Simply check the collider referenced by each contact and if it's the one you're interested in, increase a counter. This is what is done in the FluidMaze sample scene to determine if the fluid is in contact with specific dye blocks.

See "Retrieving the collider involved in a contact" in the manual's scripting section:

http://obi.virtualmethodstudio.com/manual/6.2/scriptingcollisions.html

You can also take a look at the sample script you'll find at the very end of that page. It checks if fluid is in contact with a specific trigger collider (by comparing its tag), and if so, accelerate particles in a direction opposite to gravity (effectively creating a zero-G zone).


RE: Retrieving contacts count only from a specific collision - Rearden - 14-07-2021

Thank you for the quick response! Yep, it seems like I just missed this part!