Making lots of shapes not collide with each other?

Is there an easy way to make a large number of RigidBodyControls not collide with each other, but collide with the rest of the map? Thanks in advanced.

Collision Groups.

2 Likes

@kd12 I knew about that, but I’m not sure exactly what sort of set up to use. Would it work like setting all of their collision group the same, but with a different collideWith group, or vice versa, or what? I’ll mess with it whenever I can, I’m just asking some questions so I know better what to do.

Setting everything to the same collision group would mean setting collideWith to different values would do nothing.

I haven’t used them much but I think it works like this. Say you have three groups, A, B and C. You want to A to collide with other As and Cs, Bs to collide with Cs, and Cs to collide with As and Bs but not each other, you would do something like

memberOfGroupA.setCollisionGroup(001)
memberOfGroupB.setCollisionGroup(010)
memberOfGroupC.setCollisionGroup(100)

memberOfGroupA.addCollideWithGroup(001);
memberOfGroupA.addCollideWithGroup(100);

memberOfGroupB.addCollideWithGroup(100);

memberOfGroupC.addCollideWithGroup(001) ;
memberOfGroupC.addCollideWithGroup(010) ;

Someone correct me if that’s wrong.

I figured it out, thanks. It was something like:
For each of the shapes:

thisControlThinger.setCollisionGroup(100);
thisControlThinger.setCollideWith(0);

Everything else is in 0, except for the mass amounts of parts I don’t want colliding. (I used this to help improve performance on my building destruction physics). Thanks!

Beware that groups are bit-masks.

group 0 is none => no collision at all
first group is 1. (bit 0)
second is 2. (bit 1)
third is 4. (bit 2)
fourth is 8. (bit 3)

If you want to collide with groups second and fourth, you set collideWith(2+8) (you can also make it with bit-wise or : 2 | 8)