collision detection filter problem

hi,

I want detect who item collide with my ‘wallLeftN’ and i use the prefix myid. But the problem is with my littleCharacter : my function onCollision don’t detect the target.myid ==3 and i don’t know why ???

(target.myid ==1 works but no the 3)

Could you take a look for me ? thanks

local character = display.newSprite(mySheet, sequenceData ) character:translate(240, 230) character.onlife =  true character:setSequence( "runFast" ) character.myid=2 physics.addBody( character, { density=1, friction=1, bounce=0.3,shape=pentagonShape } ) local littleCharacter = {} for i=1, number.littleCharacter do --number.littleCharacter=10     littleCharacter[i]=display.newSprite(mySheet2, sequenceData2 )     littleCharacter[i]:translate(math.random(0,440), 230)     littleCharacter[i].onlife =  true     littleCharacter[i]:setSequence( "runFast" )     littleCharacter[i]:play()     littleCharacter[i].myid = 3     physics.addBody( littleCharacter[i], { density=.11, friction=1, bounce=0.6,shape=pentagonShape } ) end local wallLeftN=display.newImageRect("wallLeft.png",10,display.contentHeight\*2) wallLeftN.myid=1 wallLeftN.x, wallLeft.y=-20,0 physics.addBody( wallLeftN, "static", { density = 0, friction = 5, bounce = 0}  ) local function onCollision( event )     target=event.target     if ( event.phase == "began" ) then         if ( target.myid==3 ) then             character:setFillColor(1,1,0)         elseif ( target.myid==1 ) then             character:setFillColor(1,0,0)         end     elseif ( event.phase == "ended" ) then           print("no")     end end wallLeftN:addEventListener( "collision", onCollision )  

Hi,

You probably want to check the other object in your OnCollision handler.

Something like:

if (event.other.myid == 3) then character:setFillColor(1,1,0) end

Doug

thanks so much both.

event.other.myid 

is the solution.

Have a nice day.

Hi,

You probably want to check the other object in your OnCollision handler.

Something like:

if (event.other.myid == 3) then character:setFillColor(1,1,0) end

Doug

thanks so much both.

event.other.myid 

is the solution.

Have a nice day.