I've collision problem

Hi

I’m newbies for corona engine,
I’ve problem about collision event,
As code below, if I need to move an object crate1 with event “touch” against an object crate2.

When I move crate1 with touch event against crate2, why The debugger not show message in print function?

I try it doesn’t work, Who can help me?

Thanks in advance
Mate

[code]
local physics = require( “physics” )
physics.start()
local crate1 = display.newImage( “crate.png” )
crate1.x = 180; crate1.y = 100
crate1.myName = “first crate”

local crate2 = display.newImage( “crate.png” )
crate2.x = 180; crate2.y = 200
crate2.myName = “second crate”

physics.addBody( crate1,“kinematic”, {isSensor = true, density=3.0, friction=0.5, bounce=0.3 } )
physics.addBody( crate2,“kinematic”, { isSensor = true,density=3.0, friction=0.5, bounce=0.3 } )
local function onLocalCollision( self, event )
if ( event.phase == “began” ) then

print( self.myName … ": collision began with " … event.other.myName )

elseif ( event.phase == “ended” ) then

print( self.myName … ": collision ended with " … event.other.myName )

end
end

local function move(e)
if e.phase == “moved” then
crate1.x = e.x
crate1.y=e.y

end
end
crate1.collision = onLocalCollision
crate1:addEventListener( “collision”, crate1 )
crate1:addEventListener( “touch”, move )

crate2.collision = onLocalCollision
crate2:addEventListener( “collision”, crate2 )

[/code] [import]uid: 58733 topic_id: 11969 reply_id: 311969[/import]

local physics = require( "physics" )  
physics.start()  
physics.setGravity(0,0)  
   
physics.addBody( crate1, {density=3.0, friction=0.5, bounce=0.3 } )  
physics.addBody( crate2, {isSensor = true,density=3.0, friction=0.5, bounce=0.3 } )  
  

this works perfectly, but i dont know if this the way you need [import]uid: 16142 topic_id: 11969 reply_id: 43644[/import]

Thanks darkconsoles
let me try to use. [import]uid: 58733 topic_id: 11969 reply_id: 43748[/import]

@sumate_it

that was not working because both crate1 and crate2 are kinematic try changing anyone to dynamic kinematic body can’t collide with kinematic or static body same way static body can’t collide with kinematic and static body both static and kinematic can only collide with dynamic body

also dynamic body can collide with every type of body hope it’s clear or you can do quick test [import]uid: 12482 topic_id: 11969 reply_id: 43758[/import]

Hi hgvyas123
Thanks for your clarify
let me try on tonight, I hope that work :slight_smile:

Mate [import]uid: 58733 topic_id: 11969 reply_id: 43761[/import]

Hi
That Perfectly. :slight_smile:

Thanks
Mate [import]uid: 58733 topic_id: 11969 reply_id: 43840[/import]