Collide problem

Hello.
 

I’m having problems with the collision objects. Hitbox object whose position was defined locally with respect to a group of objects remains on the global coordinates.

To make it clearer:
http://i.imgur.com/Qe4g7Xa.png
http://i.imgur.com/PzzjVm3.gif

local physics = require( "physics" ) local group = display.newGroup() group.x, group.y = 200, 50 local box1 = display.newRect( group, 0, 0, 30, 30 ) local box2 = display.newRect( group, 25, 25, 10, 10 ) local box3 = display.newRect( 25, 25, 10, 10 ) local box4 = display.newRect( 0, 0, 5, 5 ) physics.start() physics.setGravity( 0, 0 ) physics.setDrawMode( "hybrid" ) physics.addBody( group, "static", { box = { halfWidth = 15, halfHeight = 15 } } ) physics.addBody( box4, "dynamic", { isSensor = true } ) physics.addBody( box2, "static" ) group.name = "Box 1" box2.name = "Box 2" box4:addEventListener( "collision", function( event ) if event.phase == "began" then print( "Hit " .. event.other.name ) end end ) Runtime:addEventListener( "touch", function( event ) box4.x, box4.y = event.x, event.y end )

Can someone help me to solve this problem?

Hi @TheDen246,

You can place physics objects in separate groups, but you can’t move/scale those groups independently of each other, otherwise collision detection will be inaccurate.

This document explains it more clearly:

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

Best regards,

Brent

Hi @TheDen246,

You can place physics objects in separate groups, but you can’t move/scale those groups independently of each other, otherwise collision detection will be inaccurate.

This document explains it more clearly:

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

Best regards,

Brent