4
0
This repository has been archived on 2023-09-23. You can view files and clone it, but cannot push or open issues or pull requests.
TremendousTaxi/game/Assets/Scripts/Speedometer.cs

30 lines
637 B
C#
Raw Permalink Normal View History

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Speedometer : MonoBehaviour
{
   public Text SpeedText;
public CarController CCc;
// Start is called before the first frame update
void Start(){
}
// Update is called once per frame
void Update()
{
if(CCc==null)
CCc=FindObjectOfType<CarController>();
else
{
if(CCc.speed>=0)
SpeedText.text="v="+Mathf.Round(Mathf.Sqrt(CCc.speed)).ToString()+"km/h";
else
SpeedText.text="v="+(-Mathf.Round(Mathf.Sqrt(-CCc.speed))).ToString()+"km/h";
}
}
}