physics : a wall that allows only certain characters

hi,

How do you have a wall that allows you to pass some characters and block others with physics ?

I would do this :

local character=.... --can pass the wall physics.addBody( character, { density=1, friction=1, bounce=0.3,shape=pentagonShape } ) character.isFixedRotation = true local characterRed=... -- cannot pass the wall physics.addBody( characterRed, { density=1, friction=1, bounce=0.3,shape=pentagonShape } ) characterRed.isFixedRotation = true local wall = display.newRect(0, 20, 20, 460 )                    physics.addBody( wall, "static", borderBodyElement ) 

  thanks for your help :wink:

 You can try Physic Collision Filter here:

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

 Eddy roaminggamer has made a plugin to help you do that easier. Check it here:

 https://forums.coronalabs.com/topic/59222-collision-calculator/

 Or it you find out that is difficult to use a plugin, pm me and I will send you a simple lua module to just require and run.

I’m definitely going to start calling him “Eddy” now.

Yeah, but you need to use the ‘ie’ ending, not ‘y’  that way it’s like the '50s daddy-o

Thanks it’s works :slight_smile:

But i’m also interrested by your module khanh.dq if you agree.

  That’s okay. I have written a module myself base on Eddy’s idea ( Thank him again ). It’s simple and I just don’t want my Corona loads plugin everytime it runs :frowning:

  I check with my project and it works well. Hope you’re too. 

  Sample code:

local physicFilter = require "PhysicCollisionFilter" physicFilter.addNewTypes("Player","Enemy","Platform","Item","Npc","EnemyFire") physicFilter.addCollisionRules("Player",{"Enemy","Platform","Item","Npc","EnemyFire"}) physicFilter.addCollisionRules("Enemy",{"Platform"}) physicFilter.addCollisionRules("EnemyFire",{"Platform"}) physicFilter.dump() print("--------------------------------") print("Check player collision filter") for key,value in pairs(physicFilter.getCollisionFilter("Player")) do print(string.format("%-20s = %4d",key,value)) end

@Khanh.dq,

I guess it was probably a good learning experience to reverse engineer my code, but this is one of those case where you could have downloaded it. 

While I prefer folks use the plugin, they can get the library directly here: 

http://github.com/roaminggamer/RGCC/

  Thank Eddy. I just couldn’t find your code, so must wrote it myself because I try to avoid using plugins to get rid of waiting time :frowning:

  It’s nice to learn from others  :slight_smile:

 You can try Physic Collision Filter here:

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

 Eddy roaminggamer has made a plugin to help you do that easier. Check it here:

 https://forums.coronalabs.com/topic/59222-collision-calculator/

 Or it you find out that is difficult to use a plugin, pm me and I will send you a simple lua module to just require and run.

I’m definitely going to start calling him “Eddy” now.

Yeah, but you need to use the ‘ie’ ending, not ‘y’  that way it’s like the '50s daddy-o

Thanks it’s works :slight_smile:

But i’m also interrested by your module khanh.dq if you agree.

  That’s okay. I have written a module myself base on Eddy’s idea ( Thank him again ). It’s simple and I just don’t want my Corona loads plugin everytime it runs :frowning:

  I check with my project and it works well. Hope you’re too. 

  Sample code:

local physicFilter = require "PhysicCollisionFilter" physicFilter.addNewTypes("Player","Enemy","Platform","Item","Npc","EnemyFire") physicFilter.addCollisionRules("Player",{"Enemy","Platform","Item","Npc","EnemyFire"}) physicFilter.addCollisionRules("Enemy",{"Platform"}) physicFilter.addCollisionRules("EnemyFire",{"Platform"}) physicFilter.dump() print("--------------------------------") print("Check player collision filter") for key,value in pairs(physicFilter.getCollisionFilter("Player")) do print(string.format("%-20s = %4d",key,value)) end

@Khanh.dq,

I guess it was probably a good learning experience to reverse engineer my code, but this is one of those case where you could have downloaded it. 

While I prefer folks use the plugin, they can get the library directly here: 

http://github.com/roaminggamer/RGCC/

  Thank Eddy. I just couldn’t find your code, so must wrote it myself because I try to avoid using plugins to get rid of waiting time :frowning:

  It’s nice to learn from others  :slight_smile: