This project has moved. For the latest updates, please go here.

Resetting World

Topics: Developer Forum
Dec 5, 2012 at 8:15 AM

I need to reset a world back to its original state. I have this implemented, but am running into issues with contacts being established between objects after resetting. Before resetting the world, I destroy every body's contacts. Then I reset the positions and rotations of every body back to their original state. Some of these bodies are sensors so I need them recognize when other bodies are in contact with them. After resetting, the sensors do not establish contacts with those bodies that are reset into their collision region. Any help would be greatly appreciated.

Dec 6, 2012 at 10:06 AM

If you are using the ScreenManager Component, what if you exit the screen then add it again to simulate a reload/restart game?

Dec 6, 2012 at 6:11 PM

I need it to occur almost instantly which reloading a ScreenManager Component will not achieve. Thanks for the suggestion though :)

Dec 6, 2012 at 11:10 PM

How are you destroying the contacts? If I remember correctly, all the code to destroy a contact is internal :)

To really get rid of a contact, you need to remove it from the contact graph. The easiest way of doing this is to go into ContactManager.cs and make Destroy(Contact) public. Once you destroy the contact properly, it should work.

Dec 7, 2012 at 12:38 AM

Figured it out. I was destroying all of the contacts after I reset all the objects instead of destroying all the contacts before reseting all objects. Thanks for everyone's help.