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?
|
|
|||
|
|
|
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.) |
||||
|
|
|
If you simply set gravity to zero then the physics simulation works well for a top-down game. |
|||||||
|
|
Box2D is designed to work with two-dimensional space. On a 2D platformer game we could describe our objects with a basis XY:
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. |
|||||||||||||||
|
|
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 :) |
|||||||||
|