Saving simulation to file and reloading it again

Topics: Developer Forum, Project Management Forum, User Forum
Jan 15, 2015 at 9:26 PM
Wondering if anyone has tried to save a simulation to file in order to restore it at a later point (ie saving and loading a game).

Do I have to go looping through the bodies and store their data in XML (or similar) and then redo the regular creation again using this data.. or can we actually serialize the simulation and restore it (that would be awesome)?

Haven't found much when googling so I hope theres something I'm missing, and I don't have to invent something which I'm sure many people have solved before ;)

Farseer in Monogame on windows platform (if that matters).
Feb 20, 2015 at 11:37 AM

I found I couldn't serialize the World so had to create objects to serialize/deserialize and then create the bodies again after the deserialization. One thing that caught me out was referencing other bodies by the body_id, after deserializing and creating the bodies the id's will be different.