11-10-2021, 08:57 AM
(This post was last modified: 11-10-2021, 09:15 AM by josemendez.)
(10-10-2021, 12:12 PM)linkinb Wrote: what if I want my rope to collide with 1 type of collider, but not another type of collider, how would I set that up?
for example say i have a sphere and a cube. I want my rope to collide with the sphere but not with the cube, how would that set up look like via code?
Your rope:
Code:
var myFilter = ObiUtils.MakeFilter(1 << 1, 0);
for (int i = 0; i < rope.solverIndices.Length; ++i)
rope.solver.filters[rope.solverIndices[i]].filter = myFilter;
The sphere:
Code:
sphereObiCollider.Filter = ObiUtils.MakeFilter(ObiUtils.CollideWithEverything, 1);
The cube:
Code:
cubeObiCollider.Filter = ObiUtils.MakeFilter(ObiUtils.CollideWithEverything, 0);
That's one possibility: giving the rope a mask that only collides with category 1, placing the sphere in category 1 and the cube in category 0. You could do it in many other ways.
(10-10-2021, 12:12 PM)linkinb Wrote: Like how can i change the "Collides with" property that you see in the inspector on all obi colliders?
Filters are made of a mask and a category. The mask (the "Collides with" field) is the first parameter of the ObiUtils.MakeFilter() function. Just keep in mind the mask is a bit mask (just like Unity's layer masks), so you build it by simply or'ing together bits. For instance, to build a mask that collides with categories 1, 3, and 6:
Code:
int mask = (1 << 1) | (1 << 3) | (1 << 6);
ObiUtils.MakeFilter(mask, 0); // used category 0, could use any other.
Note you need to be familiar with bitwise operators to understand this. If you're not sure what this means, look them up. There's many tutorials around dealing with bit manipulation (in C# as well as other languages), the above link to Unity's layer masks is a good starting point as they work just like Obi's filter masks.