Correctly removing applyLinearImpulse

Hi - at the risk of duplicating an original question I posted here in the composer forum: http://forums.coronalabs.com/topic/53947-composer-correctly-removing-audioobjectslisteners/
I wonder if my issue is less related to using composer and more about the correct way to deal with physics bodies prior to changing scenes.
In particular I wonder if applyLinearImpulse requires any particular treatment before scene changes other than pausing / stopping physics?

Many thanks for any help.

Pausing physics will only stop the physics engine from being executed. It won’t null out any physics energy values, weights or the like. If you want to stop objects you don’t need to stop the engine, you want to stop the objects. Nil their linear and angular velocities and, imho, give them a temporary weld to a static object. But, you can’t escape the fact that dynamic physics object in a realistic environment simulation will always be subject to the forces within the simulated world. If you don’t want them to move, nail them down.

Thank you - if I wished to delete all physics objects in a scene and rebuild afresh on re-entry, would that be possible, or once physics is started might it be common practice to weld objects as you described, or reposition them for a game restart for example?

Hi @newbie1001,

As @horacebury says, if you want to “reset” physics objects, you should be able to reset the required properties or velocities to 0, then move them back to where they started.

[lua]

myObject.angularVelocity = 0

myObject:setLinearVelocity( 0,0 )

[/lua]

Brent

Pausing physics will only stop the physics engine from being executed. It won’t null out any physics energy values, weights or the like. If you want to stop objects you don’t need to stop the engine, you want to stop the objects. Nil their linear and angular velocities and, imho, give them a temporary weld to a static object. But, you can’t escape the fact that dynamic physics object in a realistic environment simulation will always be subject to the forces within the simulated world. If you don’t want them to move, nail them down.

Thank you - if I wished to delete all physics objects in a scene and rebuild afresh on re-entry, would that be possible, or once physics is started might it be common practice to weld objects as you described, or reposition them for a game restart for example?

Hi @newbie1001,

As @horacebury says, if you want to “reset” physics objects, you should be able to reset the required properties or velocities to 0, then move them back to where they started.

[lua]

myObject.angularVelocity = 0

myObject:setLinearVelocity( 0,0 )

[/lua]

Brent