News:

Herr Otto Partz says you're all nothing but pipsqueaks!

Main Menu

Collision and driving physics - Analysis for future development

Started by Cas, November 24, 2021, 11:43:32 PM

Previous topic - Next topic

Cas

Here's what I have been thinking about how collision and driving physics should be faced when developing a new engine that's compatible with that of Stunts, in the sense of giving a similar feel.

There should be two "moments": one when the car is completely on a driving surface and another in which the car is in the air. Of course, there are some transitions, like when the car has begin to touch the ground, but it's not fully on it yet, but this could be solved by correcting the car orientation and making it part of the "air" moment and there's also when the car is fully on the ground, but upside down. This could be just the same as normal, only the car does not respond to driving. I think this is what Stunts does and then if the car hasn't carshed, it crashes unless it gets back to normal or to the air very soon.

While in the air, the car should respond only to a constant gravity as a force, generating a parabolic movement, and preserve angular momentum, which would cause it to roll until it gets back to a surface. But then there's air friction, which provides many things when the speed is high enough, like terminal fall velocity, dissipation of roll and some air-braking. This is complex. The good thing is that, given that the math has to be done, adding "wind" does not give any additional work, so that could be a new feature. Air density and gravity could be made configurable, which again, wouldn't make it any harder or slower and would allow driving on other planets, ha, ha.

While on the ground or on a driving surface, we can first assume the car is a point and separate azimuth from the other two angles. Azimuth should be constant unless one steers. On the other hand, pitch and roll should be resulting components from the steepness at the point and they can be split via dot product against the gradient and its complement. Then, the altitude of the ground, plus the height of the car become the new altitude of the camera. This appears to be what Stunts does when the car is fully on the ground. There never is a problem with one wheel or two being in the air. Yet there is an effect if one or more wheels are in the air because the car is reaching the end of a bridge, for example. Not sure if each wheel should be calculated separately all the time or only when there are exceptions.

It looks like Stunts loads a number of planes in memory that corresponds to the tiles the car is interacting with. The plane altitude at the car position is calculated via proportions and they are sorted from top to bottom with the current car altitude among them. Then, if the car at a certain moment is no longer on a plane, the next plane towards the ground is found and the car will fall until it reaches that surface. Pretty complex, as this can induce rotation when some wheels are on one plane and others in the air or on another plane.

Then there are walls. I don't know if walls can have a non-vertical steepness. I think it makes more sense for them not to and planes could be flagged as drivable or non-drivable. There's a certain crashing speed. If you hit a wall or plane at over that speed, the car breaks. If you hit it slower, the car will adjust to the surface if drivable or bounce if non-drivable.

All this is blowing my mind. If you guys have any details that could simplify this for me to be able to start working well on physics and collision, I'll be happy to read that. Also, if there's any important detail I'm missing, please let me know. Thanks!
Earth is my country. Science is my religion.