Sometimes, setting up collision categories and collision masks can be a little bit more than you need, especially when you only need to filter the collision between two object types; just like in our case!
Let's quickly review one more method to filter collisions using the collisionGroup
property:
First of all, we need to remove the code that sets collision categories and the collision mask. In the
PhysicsHunter.m
file, find thecreatePhysicsBody
method and remove the following line:body.collisionCategories = @[@"hunters"];
Then, open the
PhysicsScene.m
file and remove the following line from theaddGround
method:groundBody.collisionCategories = @[@"obstacles"];
Also, remove the following line of code from the
spawnStone
method:stoneBody.collisionMask = @[@"hunters"];
This will remove the collision filtering that we've added in the previous Time for action section.
Now, it is time to implement collision filtering using the collision...