Today I was working with a real buggy bug that has been bugging me since pretty much the beginning of development.
You see, I choose to use box2d c++ version for Posable Heroes. It's open source and pretty solid. And the best of all, it's deterministic. That is, there is no "random" on the simulated work. If you have a square and a triangle, in exaclty the same starting position, with exactly the same linear and rotation speed, then when you simulate the world, you are always going to get the same result.
Which is good! Specially for me in a game where I have to go back in time all the time.
BUT... (a big but!)... if you try to duplicate an existing world (already running), then the two worlds will not behave the same.
Here's a picture for you to understand...
If you copy from the beginning, everything works:
But if you copy once the world is already running:
This is for a very simple reason: Box2d classes do not expose everything in public. There are several values, arrays and optimizations that lie under the hood, inside the b2World and the b2Bodies. So when you grab an existing world, and try to duplicate all the elements from the value they have public, there are several things you are missing.
I found a temporal solution that I will talk about next post and that might solve this problem for some users, but that wasn't a forever solution in my case either.
If you want to know more about my game: Posable Heroes now has a steam store page.