Collision Filtering

Hello,
 
I need help with my game, it is a simple obstacle “jumping” game, and I need to make the player not to be able to explode when hits the floor, only when it hits the rock(obstacle). I really dont know how to make this, and I need any help I can get.

I made everything, all the images are loaded, jumping is in the game (its more like using the jetpack, rather then jumping, but its still my first game :slight_smile: ), I have exploding on impact in the game and i need to make it explode only on impact between 2 things (the player and the rock), but still to be able to interact with the floor, and walk on it.
 
Thank you.

PS: if you need my code, I’ll post it

Hello @viruswarmc,

The process for setting up collision filters is documented here:

http://docs.coronalabs.com/guide/physics/collisionDetection/index.html

Take care,

Brent

Yes, thank you, I knew and read that, and I know how to use fliters, but I don’t know how to make only if 2 certain object collide explosion will occur and if any other objects collide nothing will happen, they will repel each other but not explode and end the game…

Thanks, anyway, but that did not fix it for me.

The collision filters Brent sent will for sure get the job done and really the only way, just gotta really make those maskBits and categoryBits perfect for it to work.

hmm, this is how I did it, i made player not collide with floor, neither the rock collides with floor; if I make player collide with it, it explodes, so it has to be “off”.

Player - Rock collision is alright, and when the collide explosion happens. But the player-floor is no good, player passes right through the floor, and you are supposed to “walk” on it, to be able to collide but not to die.

set up names for objects: rock.name = “rock” and floor.name= “floor”
In the collision detection function make an if clause like:
 

local function collisionDetection(event) name = event.target.name if name == "floor" then ---do nothing elseif name == "rock" then ---explode end end

Hello @viruswarmc,

The process for setting up collision filters is documented here:

http://docs.coronalabs.com/guide/physics/collisionDetection/index.html

Take care,

Brent

Yes, thank you, I knew and read that, and I know how to use fliters, but I don’t know how to make only if 2 certain object collide explosion will occur and if any other objects collide nothing will happen, they will repel each other but not explode and end the game…

Thanks, anyway, but that did not fix it for me.

The collision filters Brent sent will for sure get the job done and really the only way, just gotta really make those maskBits and categoryBits perfect for it to work.

hmm, this is how I did it, i made player not collide with floor, neither the rock collides with floor; if I make player collide with it, it explodes, so it has to be “off”.

Player - Rock collision is alright, and when the collide explosion happens. But the player-floor is no good, player passes right through the floor, and you are supposed to “walk” on it, to be able to collide but not to die.

set up names for objects: rock.name = “rock” and floor.name= “floor”
In the collision detection function make an if clause like:
 

local function collisionDetection(event) name = event.target.name if name == "floor" then ---do nothing elseif name == "rock" then ---explode end end