What do i have to use to simulate gravity from a top view game like a pool game or car game ( like GTA1 or 2) ?
How can i simulate a top view game ( gravity )
General DiscussionWhat exactly do you want to simulate? AFAIK there is not much use of gravity in GTA2, I would even say none 🙂
If I recall you could walk off ramps and the edges of buildings in GTA. And there were some bridges. So basically, your height affected which objects you could collide with. You could do some basic work like this using a custom collision filter, based on the heights of the two objects in question. And then ensure that "falling objects" (like people, cars etc) have their height position decreased everytime step when it is strictly greater than the top of any object they are overlapping (using b2World.Query, or some other method).
the problem is that i set gravity to 0 and drag the object.. the objects floats and never stops... obviusly.. what i want to do is set the velocity of all objects down to 0 after a colision, explosion or something like that.
sorry for my english.
sorry for my english.
gustavorino wrote:
the problem is that i set gravity to 0 and drag the object.. the objects floats and never stops... obviusly.. what i want to do is set the velocity of all objects down to 0 after a colision, explosion or something like that.
sorry for my english.
sorry for my english.
You probably want to simulate a friction with ground then? You can do that by applying a force to objects of -v*k, where v is current velocity of the object and k is some nice constant 🙂
Friction shouldn't be proportional to velocity. That would make it look like some sort of damping.
And also there is static and dynamic friction also to be taken in to account, so I really think it's not so straight-forward or kind of built in....
Most games do not differentiate between static and dynamic friction. As far as I know, Box2D doesn't either, even for side-view friction. It is almost always good enough to just use one kind of friction.
As far as I remember, Erin stated somewhere that Box2D takes into account both static and dynamic friction (you may have been misleaded that there is only one friction variable for the shape).
And even if you consider only one type of friction, if you simply apply the formula state above, objects look somehow floaty... unreal...
And even if you consider only one type of friction, if you simply apply the formula state above, objects look somehow floaty... unreal...
Right, Box2D has static and dynamic friciton. They use the same friction coefficient for simplicity.
Top down friction is on the TODO list.
Top down friction is on the TODO list.
Original thread: https://box2d.org/forum/viewtopic.php?t=875