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

    1. Red Dead Redemption 2

      1. PC
      2. Gameplay
      3. Missions
      4. Help & Support
    2. Red Dead Online

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

      1. Recruitment
    2. Events

    1. GTA Online

      1. Diamond Casino & Resort
      2. DLC
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Grand Theft Auto Series

    3. GTA 6

    4. GTA V

      1. PC
      2. Guides & Strategies
      3. Help & Support
    5. GTA IV

      1. Episodes from Liberty City
      2. Multiplayer
      3. Guides & Strategies
      4. Help & Support
      5. GTA IV Mods
    6. GTA Chinatown Wars

    7. GTA Vice City Stories

    8. GTA Liberty City Stories

    9. GTA San Andreas

      1. Guides & Strategies
      2. Help & Support
      3. GTA SA Mods
    10. GTA Vice City

      1. Guides & Strategies
      2. Help & Support
      3. GTA VC Mods
    11. GTA III

      1. Guides & Strategies
      2. Help & Support
      3. GTA III Mods
    12. Top Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    13. Wiki

      1. Merchandising
    1. GTA Modding

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Mod Showroom

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

      1. DYOM
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Red Dead Redemption

    2. Rockstar Games

    1. Off-Topic

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

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

    2. Forum Support

    3. Site Suggestions

Sign in to follow this  
Kilowog01

How to create a precise speedometer?

Recommended Posts

Kilowog01

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
Guest
Posted (edited)

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
ikt
Posted (edited)

I use several ways in my own mods:

 

https://github.com/E66666666/GTAVManualTransmission

 

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.
Note: Your post will require moderator approval before it will be visible.

Guest
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.