Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Collision filtering for ropes
#5
(11-10-2021, 08:57 AM)josemendez Wrote: 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.


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.


Thanks this was very helpful!
Reply


Messages In This Thread
Collision filtering for ropes - by linkinb - 10-10-2021, 07:24 AM
RE: Collision filtering for ropes - by josemendez - 10-10-2021, 11:06 AM
RE: Collision filtering for ropes - by linkinb - 10-10-2021, 12:12 PM
RE: Collision filtering for ropes - by josemendez - 11-10-2021, 08:57 AM
RE: Collision filtering for ropes - by linkinb - 11-10-2021, 02:23 PM