Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

How to make a digital speedometer?

Discussion in 'Scripting' started by Konniskatt, Jul 7, 2018.

  1. Konniskatt

    Konniskatt

    Joined:
    Jun 24, 2018
    Posts:
    26
    Hi, I need a script that can create a digital speedometer (with gui text)
    I don't want that fancy speedometer with a image, just a simple gui text that displays the speed of a car (which is the player)
    I know that in this forum are a lot of examples of what I want, but none of that examples worked.
    Sorry for my bad english
    Thanks.
     
  2. BlackPete

    BlackPete

    Joined:
    Nov 16, 2016
    Posts:
    970
    Are you looking for someone to create that script for you? If so, you may want to head over to the Unity Connect forum.
     
  3. Chocolade

    Chocolade

    Joined:
    Jun 19, 2013
    Posts:
    932
  4. Konniskatt

    Konniskatt

    Joined:
    Jun 24, 2018
    Posts:
    26
    thanks anyway
     
  5. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    Your object's velocity on the Z axis is already a simple speedometer in meters per second (assuming you're using the default 1 unit = 1 meter scale). Just write that value to a text object. If you want the speedometer in KPH or MPH just do the simple conversion first.

    If you don't know what any of that meant, step back and start with some basic tutorials on the topics of gameobjects, rigidbodies, and UI.
     
  6. Konniskatt

    Konniskatt

    Joined:
    Jun 24, 2018
    Posts:
    26
    All those tutorials on youtube have this horrible fancy neddle I want a DIGITAL speedometer.
    Thanks anyway
     
  7. yamaspoes

    yamaspoes

    Joined:
    Jan 7, 2022
    Posts:
    1
    simply use rigidbody.velocity.magnitude :)
     
  8. SourGummi

    SourGummi

    Joined:
    Nov 14, 2021
    Posts:
    96
    a digital speedometer like this: ...?


    if you break it down

    you're drawing a line from the center, to a speed (point on circumference)
    so just map your speed 0-200, to 0*-180* degrees. and find the point on the circle that matches your speed. draw a line from origin to speed.