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
Wirezat fd1b9d85ab
sppeed ui
Co-authored-by: Lukas Langrock <lukas.langrock@mailbox.org>
2022-09-25 11:15:59 +02:00

30 lines
637 B
C#
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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";
}
}
}