Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using TMPro;
- public class PlayerController : MonoBehaviour
- {
- //speedometer
- [SerializeField] TextMeshProUGUI speedometerText;
- [SerializeField] float speed;
- private Rigidbody playerRb;
- private void Start()
- {
- playerRb = GetComponent<Rigidbody>();
- }
- void FixedUpdate()
- {
- speed = Mathf.Round(playerRb.velocity.magnitude * 3.6f);
- speedometerText.SetText("Speed: " + speed + "kph");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement