Box2d: Disable collision between physics bodies
There are three ways of disable collision between physics bodies.
1- By using Sensor property
2- By using Group Indexes
3- By using Category and mask bits
We will discuss each of these one by one.
Sensor is associated with b2Fixture. If you will set this property of fixture true then fixture will not collide with any thing even with ground floor but you will receive a collision call back. To understand this consider this example.
You have a ball, a player and a ground floor in your game play. World gravity is -10.0, Ball restitution is 1.0. Ball falls towards ground floor due to gravity and bounces forever due to maximum restitution.
Now if you will set the Sensor property of ball fixture then ball will not collide with any thing and fall down from ground floor. But you will receive collision call back when ball will hit any thing like before.
What If You want to disable collision between some specific objects of same or different type?
In theses cased we will use other two methods Group indexes and Category, Bits which I will discuss in next post
Feel free to ask any question.