ERROR: Cannot translate an object before collision is resolved.

Does anyone get this type of message? I have a sensor that gives me a location to then translate another object to and i get this. [import]uid: 8192 topic_id: 7931 reply_id: 307931[/import]

ERROR: Cannot translate an object before collision is resolved.

**#### Hey i got the same problem at the complete execution of my game, i am using

  • Corona Simulator trial pack (version 2011.484)
  • Mac OS X Version 10.6.7.**

please any one HELP!!!

BY- DEEPAK SINGH RAWAT
please reply me at: deepak.rawat@rensoftglobal.com
[import]uid: 52000 topic_id: 7931 reply_id: 40110[/import]

You’re probably trying to perform the translation in the “began” phase of the event.
Save the value, set a flag and perform the translation outside of the event handler.

/ Ingemar [import]uid: 70847 topic_id: 7931 reply_id: 43438[/import]

I have also faced the same problem. I have an object moving to a direction. When that object hits any other object it should comes to its initial position.

Here is my code given below :

-- This is the object that will move  
local box= display.newRect(200, 250, 50, 50)  
box:setFillColor(204, 243, 255)  
physics.addBody(box, { radius =28 } )  
  
-- This is the code detecting the collision  
local function onGlobalCollision( event )  
 if ( event.phase == "began" ) then  
  
 print( "Global report: collision began" )  
 box.x = 200  
 box.y = 250  
  
 elseif ( event.phase == "ended" ) then  
  
 print( "Global report: collision ended" )  
  
 end   
end  

Please suggest… [import]uid: 154400 topic_id: 7931 reply_id: 127895[/import]

I have also faced the same problem. I have an object moving to a direction. When that object hits any other object it should comes to its initial position.

Here is my code given below :

-- This is the object that will move  
local box= display.newRect(200, 250, 50, 50)  
box:setFillColor(204, 243, 255)  
physics.addBody(box, { radius =28 } )  
  
-- This is the code detecting the collision  
local function onGlobalCollision( event )  
 if ( event.phase == "began" ) then  
  
 print( "Global report: collision began" )  
 box.x = 200  
 box.y = 250  
  
 elseif ( event.phase == "ended" ) then  
  
 print( "Global report: collision ended" )  
  
 end   
end  

Please suggest… [import]uid: 154400 topic_id: 7931 reply_id: 127895[/import]

Hi I have fixed the problem. Actually I need to set the position with a delay when the object get collides. [import]uid: 154400 topic_id: 7931 reply_id: 128124[/import]

This problem is one of the most common and occurs because the Box2D physics “world” is “locked” during collision (and other) events. The recommended way to deal with it is the set a timer for a very short period which will then execute the change you want to make.

Eg:
[lua]-- This is the object that will move
local box= display.newRect(200, 250, 50, 50)
box:setFillColor(204, 243, 255)
physics.addBody(box, { radius =28 } )

– This is the code detecting the collision
local function onGlobalCollision( event )
if ( event.phase == “began” ) then

print( “Global report: collision began” )

– use timer to update the box
timer.performWithDelay( 1, – 1 millisecond delay
function() – anonymous function to perform the update
box.x = 200
box.y = 250
end
, 1) – only execute the timer once

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

print( “Global report: collision ended” )

end
end[/lua] [import]uid: 8271 topic_id: 7931 reply_id: 128130[/import]

Hi I have fixed the problem. Actually I need to set the position with a delay when the object get collides. [import]uid: 154400 topic_id: 7931 reply_id: 128124[/import]

This problem is one of the most common and occurs because the Box2D physics “world” is “locked” during collision (and other) events. The recommended way to deal with it is the set a timer for a very short period which will then execute the change you want to make.

Eg:
[lua]-- This is the object that will move
local box= display.newRect(200, 250, 50, 50)
box:setFillColor(204, 243, 255)
physics.addBody(box, { radius =28 } )

– This is the code detecting the collision
local function onGlobalCollision( event )
if ( event.phase == “began” ) then

print( “Global report: collision began” )

– use timer to update the box
timer.performWithDelay( 1, – 1 millisecond delay
function() – anonymous function to perform the update
box.x = 200
box.y = 250
end
, 1) – only execute the timer once

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

print( “Global report: collision ended” )

end
end[/lua] [import]uid: 8271 topic_id: 7931 reply_id: 128130[/import]