physics body + group's transition = bug?

Hybrid view shows that a platform’s body moves with group transition, but a hero’s behavior evidences that it didn’t move.

What is wrong with my code?
Thank you for any help.

[code]
local physics = require( “physics” )

physics.start()
physics.setGravity(0 , 9.75);
physics.setScale( 30 )
physics.setDrawMode( “hybrid” )

local hero = display.newRect(0, 0, 20, 20)
hero:setFillColor(11, 174, 174)
hero.x = display.contentCenterX
hero.y = 0
physics.addBody(hero,“dynamic”, { density = 1, friction = 10, bounce = 0.3})

local platform = display.newRect(display.contentCenterX -100, display.contentHeight-100 , 200, 20)
platform:setFillColor(11, 14, 174)
physics.addBody(platform , “kinematic”, { density = 1, friction = 10, bounce = 0.3})

local group1 = display.newGroup()
group1:insert(platform)
transition.to( group1, { time=5000, y= group1.y - 200} )

[/code] [import]uid: 193524 topic_id: 34518 reply_id: 334518[/import]

Hello @nosty,
While you -can- move physical objects by moving the display group they’re within, it will not move those objects in the “physical world” pertaining to collisions. The reason is, for proper internal mathematical collision detection, the objects need to remain in the same coordinate space, with a top-left coordinate of 0,0 pertaining to physics. If you shift one display group to 1000,1000, objects within will assume a 0,0 group position in regards to physics.

Certainly, you are allowed to reposition physical objects within the -same- display group. Or, I suppose you could shift -all- of your display groups equally and the collisions would remain functional, because all of the groups would still share the exact same offset location.

Best regards,
Brent [import]uid: 200026 topic_id: 34518 reply_id: 137277[/import]

Thank You Brent,
This bug strongly reduces groups using :frowning: Now I must move several dozen objects instead of one group…
And fake hybrid view is addiotionally confusing.

As I can see there is no information about this in API manual and tutorials.

Is this possible to fix this bug in the near future?
[import]uid: 193524 topic_id: 34518 reply_id: 137356[/import]

Hey Nosty - this is documented in the Physics guide.

http://developer.coronalabs.com/content/game-edition-box2d-physics-engine

When working with Corona display groups and Box2D, it is important to keep in mind that Box2D expects all physics objects to share a global coordinate system. This means that a set of ungrouped Corona objects will work well, and a set of objects that are all added to the same display group should also work, since they will share the internal coordinates of that group – this is demonstrated in the “EggBreaker” sample code, which uses a single moving display group to create a “moving camera” effect.

However, unexpected results may occur if physical objects are added to different display groups, especially if the groups are then moved in different directions. The “hybrid” draw mode makes these issues much easier to diagnose, since it lets you overlay the physics engine’s collision boxes and shapes on top of the Corona renderer. [import]uid: 33275 topic_id: 34518 reply_id: 137358[/import]

Hello @nosty,
While you -can- move physical objects by moving the display group they’re within, it will not move those objects in the “physical world” pertaining to collisions. The reason is, for proper internal mathematical collision detection, the objects need to remain in the same coordinate space, with a top-left coordinate of 0,0 pertaining to physics. If you shift one display group to 1000,1000, objects within will assume a 0,0 group position in regards to physics.

Certainly, you are allowed to reposition physical objects within the -same- display group. Or, I suppose you could shift -all- of your display groups equally and the collisions would remain functional, because all of the groups would still share the exact same offset location.

Best regards,
Brent [import]uid: 200026 topic_id: 34518 reply_id: 137277[/import]

Thank You Brent,
This bug strongly reduces groups using :frowning: Now I must move several dozen objects instead of one group…
And fake hybrid view is addiotionally confusing.

As I can see there is no information about this in API manual and tutorials.

Is this possible to fix this bug in the near future?
[import]uid: 193524 topic_id: 34518 reply_id: 137356[/import]

Hey Nosty - this is documented in the Physics guide.

http://developer.coronalabs.com/content/game-edition-box2d-physics-engine

When working with Corona display groups and Box2D, it is important to keep in mind that Box2D expects all physics objects to share a global coordinate system. This means that a set of ungrouped Corona objects will work well, and a set of objects that are all added to the same display group should also work, since they will share the internal coordinates of that group – this is demonstrated in the “EggBreaker” sample code, which uses a single moving display group to create a “moving camera” effect.

However, unexpected results may occur if physical objects are added to different display groups, especially if the groups are then moved in different directions. The “hybrid” draw mode makes these issues much easier to diagnose, since it lets you overlay the physics engine’s collision boxes and shapes on top of the Corona renderer. [import]uid: 33275 topic_id: 34518 reply_id: 137358[/import]