title: Unity Car Game display Kph Speed on Text
body: <p>I want to display the car speed kph on the screen but I only have 0kph and it is not working.. though I have this code.. any suggestions will be great thank you </p>
  
  <p><a href="https://i.stack.imgur.com/FmosK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FmosK.png" alt="enter image description here"></a></p>
  
  <pre><code>public Text text;
  private double Speed;
  private Vector3 startingPosition, speedvec;
  
  void Start () 
  {
      startingPosition = transform.position;
  }
  
  void FixedUpdate()
  {
      speedvec = ((transform.position - startingPosition) / Time.deltaTime);
      Speed = (int)(speedvec.magnitude) * 3.6; // 3.6 is the constant to convert a value from m/s to km/h, because i think that the speed wich is being calculated here is coming in m/s, if you want it in mph, you should use ~2,2374 instead of 3.6 (assuming that 1 mph = 1.609 kmh)
  
      startingPosition = transform.position;
      text.text = Speed + "km/h";  // or mph
  
  }
  </code></pre>
  
  <p>Any renewal / new edit of the code will be great. Thank you</p>