Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. The Cayo Perico Heist
      2. The Diamond Casino Heist
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Red Dead Online

      1. Frontier Pursuits
      2. Find Lobbies & Outlaws
      3. Help & Support
    3. Crews

    1. Red Dead Redemption 2

      1. PC
      2. Help & Support
    2. Red Dead Redemption

    1. Grand Theft Auto Series

    2. GTA VI

      1. St. Andrews Cathedral
    3. GTA V

      1. Guides & Strategies
      2. Help & Support
    4. GTA IV

      1. The Lost and Damned
      2. The Ballad of Gay Tony
      3. Guides & Strategies
      4. Help & Support
    5. GTA San Andreas

      1. Guides & Strategies
      2. Help & Support
    6. GTA Vice City

      1. Guides & Strategies
      2. Help & Support
    7. GTA III

      1. Guides & Strategies
      2. Help & Support
    8. Portable Games

      1. GTA Chinatown Wars
      2. GTA Vice City Stories
      3. GTA Liberty City Stories
    9. Top-Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    1. GTA Mods

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Red Dead Mods

      1. Documentation
    3. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    4. Featured Mods

      1. Design Your Own Mission
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Rockstar Games

    2. Rockstar Collectors

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Movies & TV
      5. Music
      6. Sports
      7. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    3. Gangs

    1. Announcements

    2. Support

    3. Suggestions

Sign in to follow this  

How to create a precise speedometer?

Recommended Posts


There are many speedometers out there but unfortunately they don't suit me. Current mods calculate speed based on the position of the car and i want a speedometer that simulates the actual working of a car. Calculating the wheel rotation, multiplying by wheel size and converting to km/h or mph. I intend to use it on a roleplay server, this will be base for many Interactions between players and I've had many problems with flicking values and Desync so it needs to work properly and be simple at the same time.


Can you guys help me?

Share this post

Link to post
Share on other sites

Real cars work differently (or used to) because they didn't have the technology to know how fast they are moving in relation to the real world.What I mean by that, is they don't know where you are and where you were previously and how long it took for you to travel between those two points. It is only recently that GPS based speedometers have come into being and those will work the same way as the calculations do in GTA V. They will measure your position and then a fixed time later, they will measure it again. Using the time taken to travel that distance, will give you the speed you are travelling at.


*<snip>* Lots of useless waffle removed.


Edit: Actually, thinking about this, the current speed and velocity are already handled by the game and are properties of the Vehicle (or Entity) class. So all the current speedometers should be doing, is taking that velocity and using the time interval to get the overall speed per hour.


The more I think about this, the more I am even overcomplicating things...


Here's some code I use in one of my display mods to get the speed:

int displaySpeedMPH = (int)(CurrentVehicle.Speed * 2.236936f);
int displaySpeedKMh = (int)(CurrentVehicle.Speed * 3.6f);

It can't get much simpler than that... I don't even use the time interval.


Just one final quote to clear up the confusion about how car speedometers actually work. Source: https://www.howacarworks.com/accessories/how-a-speedo-works


"A flexible drive cable inside a flexible tube links a small magnet inside the speedometer to the gearbox output shaft.


The magnet rotates with the shaft and its magnetic field attracts a metal drum to turn the speedometer needle against the force of a hair spring. The needle moves round the dial until the restraining force of the hair spring brings it to rest to give a reading of the road speed."


No tyres or wheel dimensions, or rotation speeds involved.

Edited by Guest

Share this post

Link to post
Share on other sites

I use several ways in my own mods:




I use some of the following

- Use the wheel speed and calculate the road speed using the tyre radius.

- Use the engine RPM and gearing ratio. Will be inaccurate if the clutch is used (idle, during shifting)

- There's a bunch of ways to figure out which wheels are powered so your best estimation would be to average the rotation speed of the powered wheels and multiply that speed with the tyre radius.

- There's also a dashboard readout thing that most cars have, but some cars miss this and that value would stay 0.0.



Edited by ikt

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.