Problems with Iforce2D car physics

Here's the place to get help and discuss features. The focus is on the C++ version, but generic questions are welcome.
gamelord
Posts: 2
Joined: Sat Mar 18, 2017 7:50 am

Problems with Iforce2D car physics

Postby gamelord » Sat Mar 18, 2017 8:56 am

Iforce2d is a website that has tutorials of Box2d car physics.

Firstly, here is a video showing how a real car turns at slow-speeds (From Live For Speed, a realistic driving game.)
Image

But...Here is what I get after using Iforce2D's car tutorial:
Image
In this video, the backend and front end are not united, and slightly drifts even at low speeds of 1 mile an hour. Real cars do not slip or drift at all at 1 mile per hour. Also, note the thing of this video, the density of the chassis was set to 0.1, close to the density of styrofoam or very light wood...The next video will show you how a car with the density closer to metal performs...
Image

In short, the problem with Iforce2D is that it drifts even when the car is moving at very low speeds, and even disabling the function of a MaxAngularImpulse will not help. I suspect he added the MaxAngularImpulse function to disguise the fact that the car inherently drifts at low speeds. The other problem with Iforce2D is that it's drifting is not at all realistic at high speeds, and configuring it to have realistic opposite lock behavoir is almost impossible.

There are other car tutorials online, however the Box 2D I am using is with Game Maker, and doesn't have functions like KillOrthogonalVelocity or SetLinearVelocity. When I use the AddImpulse functions... things go differently than you'd expect.

Here is a video of my custom code, which applies the lateral cancelling to the car body itself, rather than the tires. This produces a much more realistic behavoir at low speeds.
Image[/img]

My guess is the reason Iforce2d's code does not follow it's intended behavoir (which is to have 100% grip at low speeds, like the video directly above), is because each tire is cancelling the other tires out. The tires cancel out the lateral velocity of themselves, but cannot decide which tires to cancel out or in what order or magnitude to cancel themselves out. Since when a real-life car turns, the front of the car always has a different lateral velocity of the back of the car, and the side of the car has a different lateral velocity than the outside side of the car, ie. the drivers seat feels different g-forces in a turn than if you are sitting in the passenger seat...Therefore if the lateral velocity is totally cancelled out for each tire, and the lateral velocity of each tire is set to zero, you actually will probably get an incorrect turning behavoir of the car. The second issue is also a joint distribution issue, when the car chassis is of a realistic weight, the car tires don't have the same influence as when the car chassis is almost zero weight, and so the car chassis hovertanks and disrupts the influence of the tires in an unrealistic way. Ie., the engine can't decide in what way to prioritize the lateral velocity cancelling, and so gives it a kind of blend, where each tire kinds of blends it together and also kind of mixes it with the car's hovertank influence, causing unrealistic behavoir.
Because the tires don't realistically behave as real tires with rolliing friction, they are only artificially having their lateral velocity removed, they don't coherently turn the car in the way a real tire would.

For example, in a real life car, the car has different lateral velocities at different positions of the car...For instance, the drivers seat has a different g-force and lateral velocity than a passenger's seat. So it doesn't make any sense that simply nullifying the lateral velocity of each tyre would produce desired behavior. Indeed, the very theory of Iforce2D produces inconsistent behavoir...for instance, if you set the car to a low density, it drifts a small amount, and when you set the car to the density of metal, it drifts uncontrollably....when, in theory, implied by the iforce2d tutorial, if you set MaxLateralImpulse to a high value like 200,000, the car should be clamped and have no lateral velocity at all.

Now you might say, what's the problem "yo, it's just a kid's game or casual game, or simple 2d game, etc". But it just doesn't look right or feel right to play, both for low-speed and high-speed turns. Something about it seems "off" like you aren't really driving a car. Arcade games are not realistic, but they are specifically designed so that you feel like you are driving some kind of car.

The guy who made Iforce2D car theory, even said his code was "not fun". The car does not turn correctly at high speeds, the drifting does not look like real drifting and it is not even close to real car behavoir. If even the guy who made it believes it is "not fun" and believes it is not ready to be used in a game without serious tweaking (his words)...I am not sure why he released it, other than to get views for his website. But...Every man's got to make a living.

I made a custom code, that causes realistic turning at low speeds. However, this becomes a fail at high speeds, so I am going to be looking around and browsing for better car physics on the forums.

My code, though good for low speeds, is not very good for high speeds. I am looking for something along the lines of Burnout, Need For Speed, or R.Racing with automatic slipping during cornering at speeds over 25 miles per hour. Game Maker Box 2D has no SetLinearVelocity function, and for some reason, setting an impulse multiplied by the phy_mass doesn't seem to work as precise as you'd expect. Please help me and point me to the right direction.

irresistible force
Posts: 1991
Joined: Tue Jun 24, 2008 8:25 pm
Location: Tokyo
Contact:

Re: Problems with Iforce2D car physics

Postby irresistible force » Sun Mar 26, 2017 9:21 am

As you've discovered, if you're serious about making a driving game, with nice drifting and countersteer, that method is not much use. I wasn't expecting it to be so "not fun" when I started making the tutorial :) Then I didn't see any reason not to make it public after writing it - I mean, it's not like every tutorial has to be AAA game-ready quality to be useful for somebody.

gamelord
Posts: 2
Joined: Sat Mar 18, 2017 7:50 am

Re: Problems with Iforce2D car physics

Postby gamelord » Sun Apr 09, 2017 2:37 pm

I don't need it to be AAA or AA quality, I'll settle for an A or a B+. Have you worked on car physics some more?


Return to “General Discussion”



Who is online

Users browsing this forum: No registered users and 1 guest