Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can top view physics games be done in box2D? One idea I have is to set the linear velocity of an object manually or to alter the linear and angular damping as my object moves over different surfaces. For example if my object is over a wet surface it'll have less linear damping and if it is over rough surface it'll have more damping. And to see if my object has fallen over an edge I'll try to use an AABB and check if its still inside or manually see if object.x > boundary.x etc. Is there any better way?

share|improve this question
up vote 5 down vote accepted

Look into b2FrictionJoint to simulate top-down "rough surfaces". Motion damping doesn't end up looking that realistic.

You can basically attach your objects to anything using a friction joint to get it to work. (I attach them all to a floor object, but it doesn't matter how big or where it is.)

share|improve this answer

If you simply set gravity to zero then the physics simulation works well for a top-down game.

share|improve this answer
Disabling gravitiy doesn't turn Box2D into a top-down physics simulation. How would you simulate ground friction? What about a car that drives through mud? – bummzack Jun 24 '11 at 7:03
I would do that by changing the car's density or friction or something using sensors for the mud area. Admittedly that's semantically hacky because that's not the intended purpose of those features, but it's a simple way to keep having Box2D do all the work for you. – jhocking Jun 24 '11 at 12:18

Box2D is designed to work with two-dimensional space. On a 2D platformer game we could describe our objects with a basis XY:

--------- X

In this game there is no depth, ok? If we want see this same game with a top view, our space need a third new dimension Z, to describe depth. What happens? Now we have three dimensions but Box2D is designed in two dimensions.

The game can be visually two-dimensional, but the logic is three-dimensional in this case. ( top-view ).

I think that will be better use another 3D physics library, or implement one yourself.

I never have seen a top view game using Box2D and I would be very grateful if someone knows one.

share|improve this answer
I disagree that the "logic" would necessarily be 3D. For a 2D game, Z is usually just the order in which objects are drawn for visual purposes. This doesn't need to be simulated or tied to the physics at all. – Brian Ortiz Mar 7 '11 at 17:26
I've said that in "this case" we need a logic three-dimensional.The Z that you said is not a new dimension, it's only a form to describe the relative order in that the sprites must be drawed. ( painter algorithm ) – momboco Mar 7 '11 at 17:35
In Box2D the Y coordinate is the altitude ( and that to which the gravity is applied ). I don't know how to change this if you want a game with top-view. Because if you use gravity, then you loose a dimension and it's needed a third dimension. – momboco Mar 7 '11 at 17:39
Here is a top-down game that uses Box2D: I happen to know this because I helped program it :P The vehicle movements are a bit hacky, with manual setting of the rotation, and friction over grass is also done manually, but the rest (acceleration, bumping & bouncing, collision with the environment) is pure Box2D. – Bart van Heukelom Mar 7 '11 at 21:59
Thanks a lot. I have some questions. The collision with the environment only produces that the car stops. Do you think that the rebound can be acomplished with Box2D? The friction over the grass is manually implemented due to some limitation of Box2D? When I've developed games with top-view sometimes I've used 3d logic with z for altitude, and then associate this value to a scale ( for example, a casing that is launched from a pistol). With Box2D I have not found how to deal with this. – momboco Mar 7 '11 at 22:40

As jhocking said, its the same using Box2D for a side or top view.

Just disable gravity and play with depths using the colision filtering in the box2D manual.

because there will be no gravity force, the objects will be "lighter" than normal, when pushing them. Play with the masses and the forces to achieve equivalent results.

What you refered to as damping, should be the common friction in Box2D, i think. and as for checking limits of your levels, there are sensors. shapes that will tell you when something passes over :)

share|improve this answer
"because there will be no gravity force, the objects will be "lighter" than normal, when pushing them": Why? Their mass hasn't changed just because gravity is missing. – alxx Apr 30 '11 at 17:56
Their mass wont change. But gravity will no longer hold them to the ground, so when they are not touching a surface, they will be easier to move. – AttackingHobo May 9 '11 at 18:02

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.