Jump to content
  • Advertisement
  • entries
    37
  • comments
    65
  • views
    47441

Replicating a simulation with Box2d, part 1.

Sign in to follow this  
desdemian

1003 views

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:

mExImPu.png

 

But if you copy once the world is already running:

nyPOtNG.png

 

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.

Sign in to follow this  


0 Comments


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!