Page 1 of 3 123 LastLast
Results 1 to 10 of 25

Thread: basic yet mysterious physics engines

  1. #1
    Custom Title Honors BuzzKillington's Avatar
    Join Date
    Dec 2008
    Posts
    2,492

    Default basic yet mysterious physics engines

    In racing games such as Gran Tourismo or even your basic java drag racing games like "Nitto 1320" cars can be modded and gear ratios adjusted all effecting how the car performs.

    How does this work? What tells the game what mods make what difference and what ratios do what with the cars acceleration/speed? While in real life there is no set number, I find it hard to believe in a game there isn't some sort of algorithm that tells the game what works and what doesn't.

    It's odd to me that something so complex can be added to very "basic" racing games. This is really blowing my mind. My head hurts.


    PS3: CaptBuzzCooler

  2. #2
    Mentally Underclocked mDust's Avatar
    Join Date
    Aug 2009
    Location
    Michigan
    Posts
    1,639

    Default Re: basic yet mysterious physics engines

    A mathematical formula can be devised to describe anything. I've seen attempts to discover the meaning of life that blow everyone's mind. There is definitely an equation that consists of every chemical, electrical and mechanical input and output for a vehicle...it would be incredibly complicated. It's complexity would scale with accuracy. Gear ratios would be a tiny part of it. You'd damn well better be a mechanical/automotive engineer, an inventor, or really really f***ing curious to have an excuse to figure any of it out. There are geniuses walking among us that routinely describe everyday, ordinary things with complex equations just for fun. I've seen it happen before and I don't pretend to understand it.
    I'll procrastinate tomorrow.

  3. #3
    Custom Title Honors BuzzKillington's Avatar
    Join Date
    Dec 2008
    Posts
    2,492

    Default Re: basic yet mysterious physics engines

    But how are basic racing games getting ahold of this wonder of the universe!? It's driving me insane! I started writing it out but got nowhere.

    Scenario:
    4 gears. Each gear has a setting of 1-10. Does the game know the magic numbers that are best for that specific vehicle? Let's say they are 10-8-6-5. Is it a game of "Hot & Cold"? 4-3-2-1 COLD! Your car sucks, it's way off! 9-8-6-5. HOT! You're burning up! You're car's fast but not performing 100%.

    Throw in different combinations of car modifications, aerodynamics, tire pressure, final drives, gear ratios to the 0.000 range and my head explodes. Is it the holy grail of scripts or are developers coming up with these rules on their own? I need to learn! lol
    PS3: CaptBuzzCooler

  4. #4
    Mentally Underclocked mDust's Avatar
    Join Date
    Aug 2009
    Location
    Michigan
    Posts
    1,639

    Default Re: basic yet mysterious physics engines

    Hell no game developers aren't coming up with this on their own...or at all. Car manufacturers and their race teams figure it out. They over-engineer every single part to optimize performance...to win. This is why any typical race car is generally several million dollars.
    I'll procrastinate tomorrow.

  5. #5
    Custom Title Honors BuzzKillington's Avatar
    Join Date
    Dec 2008
    Posts
    2,492

    Default Re: basic yet mysterious physics engines

    but how are they converting this to game lingo? How does the game determine what numbers make the car perform better? In real life I understand the concept but in a game there's no way a basic free game can implement such complex stuff. There's gotta be a set "puzzle" if you will that is the hidden goal. Maybe they throw you off by allowing perfect shifts to last 100-500 rpms / .5-1.5seconds in motion. That's a huge window when you're talking drag racing. Shifting at the beginning of the perfect shifts can make a huge impact (for better or for worse) than if you were to shift at the end of the perfect shift window.
    PS3: CaptBuzzCooler

  6. #6
    Mentally Underclocked mDust's Avatar
    Join Date
    Aug 2009
    Location
    Michigan
    Posts
    1,639

    Default Re: basic yet mysterious physics engines

    The physics engine takes basic figures and plugs them into known equations to simulate gravity, impacts, explosions, and in this case various forces on a car. How much is accurate and how much is fudged depends on what the game developer felt was best for the game.

    Some code ran that computed an 'efficiency value' and an if then statement determined 'how good' it was.

    EDIT: Here you go. It's for trucks, but the principle is the same. Certain gear ratios will yield more or less performance depending on tire size. The game designers likely used a more complicated but similar data set to determine car performance in game. Nested if then statements and algebra is a powerful thing.
    I'll procrastinate tomorrow.

  7. #7
    I got rid of my floppy disks Xpirate's Avatar
    Join Date
    Apr 2007
    Location
    Texas
    Posts
    537

    Default Re: basic yet mysterious physics engines

    I made a very basic drag race game about ten years ago. The output was just a line of output at the DOS prompt that constantly updated with every execution step.

    I used a parabolic function to determine torque based on RPM. It was very basic, but I eventually got it to where you had to correctly go through all the gears to get better times.

    This is all I had documented in the code (I really, really should have taken better notes):

    Formulas:
    Torque = (RPM / 15.0) - ( (RPM * RPM) / 120000.0 ) + torqueChange;
    This is the formula for an upside down parabola

    HP = (Torque * RPM) / 5252.0;
    5252.0 == conversion factor for torque to HP

    Accel = (Torque * Gear * 4) / 109.0; Unit of feet/second^2
    109.0 == mass of the car in slugs

    MPH += 0.6818 * Accel * 0.01;
    0.6818 == convert feet/second to MPH
    0.01 == time interval in seconds

    RPM = MPH * 11.2 * Gear * 4.0;
    4.0 == rear axle ratio
    11.2 == ???

    Distance += MPH * 0.01467;
    0.01467 == conversion for MPH, unit of feet
    derived ???

  8. #8
    Custom Title Honors BuzzKillington's Avatar
    Join Date
    Dec 2008
    Posts
    2,492

    Default Re: basic yet mysterious physics engines

    So with that formula it appears one couldn't actually calculate an ideal ratio. actually, it looks like the gears are pre-set, just the possibility to shift at ideal rpms. That's definitely part of the code I'm looking for but in this game it ranges from 1.000-5.000 and everything in between.

    I wonder if I could just skip this mess and pay someone to reverse engineer an android game and automate the revs and shifting to eliminate human error while testing ratios. $250 bucks if anyone is interested.
    PS3: CaptBuzzCooler

  9. #9
    Code Monkey NightrainSrt4's Avatar
    Join Date
    Jun 2007
    Location
    Your cookie jar
    Posts
    2,679

    Default Re: basic yet mysterious physics engines

    The wiki actually has a good set of information on this. All the equations shown can easily be turned into algorithms with variables.

    Wiki:
    For example, it is possible to determine the distance the car will travel for one revolution of the engine by dividing the circumference of the tire by the combined gear ratio of the transmission and differential.

    d = c_t / (gr_t * gr_d)

    It is possible to determine a car’s speed from the engine speed by multiplying the circumference of the tire by the engine speed and dividing by the combined gear ratio.

    v_c = (c_t * v_e)(gr_t * gr_d)
    It all HAS to be broken down into a set of mathematical equations, which themselves are easily converted into algorithms. Take for example we know the gear ratio of my car. I don't change my tires for anything larger, or smaller. If I am in 3rd gear, and going 3,000RPM, I already know my speed without having to look at the speedometer. All things equal, my speed will always stay the same with the same gear, the same gear ratio, and the same RPMs. Given all the data for a series of points, you could get a rough estimate of the equation just with the data from one car.

  10. #10
    Custom Title Honors
    Join Date
    Feb 2011
    Posts
    1,078

    Default Re: basic yet mysterious physics engines

    first off, i think the OP is over thinking it a bit too much. there isn't a magical combination of settings that makes a car perform better than anything else. it all comes down to the driver.

    so there would be calculations for gravity, downforce, lateral forces, acceleration due to gear ratios, etc, etc. but all of that means nothing until you have a driver that can drive the way it's set.

    for example, the very first porsche race car built by automobile union in germany in the 30's was virtually undrivable because of the placement of the engine in the back like today's porsches. so what the auto union team did was hire a motorcycle racer (someone who didn't have a clue how a race CAR was supposed to handle) and that dude took the "ill-handling" auto union car out and commenced to stomp all over mercedes and everyone else.

    the point here is that the auto union car was very far from what was considered ideally setup, but once someone showed up that could drive it, those settings became ideal for that person.

    i hope that helps to understand that there is no hot and cold settings for these games. only calculations as to how the setting effects the way a car handles.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •