Hi!
I our game we have dynamic objects that have initial positions, and then, when the player collides with them, they start flying around. If the player clicks "Restart Level" I want those objects to be reset at their original positions and their forces "reset" to what they were when the level was created, ie. the object completely stopped.
What is the correct way to reset the forces? I am using body::setXForm() to set the positon and angle and then body::putToSleep() and directly after that body:wakeUp() to reset the forces but the objects sometimes seem to have some small forces that are not reset. Eg. a pile of barrels stands still when loading the level the first time, but falls over by itself after a while after restarting the level.
So, what is a good way to make a dynamic object behave as if it was just created and no forces yet applied to it.
I our game we have dynamic objects that have initial positions, and then, when the player collides with them, they start flying around. If the player clicks "Restart Level" I want those objects to be reset at their original positions and their forces "reset" to what they were when the level was created, ie. the object completely stopped.
What is the correct way to reset the forces? I am using body::setXForm() to set the positon and angle and then body::putToSleep() and directly after that body:wakeUp() to reset the forces but the objects sometimes seem to have some small forces that are not reset. Eg. a pile of barrels stands still when loading the level the first time, but falls over by itself after a while after restarting the level.
So, what is a good way to make a dynamic object behave as if it was just created and no forces yet applied to it.