I found a nice tutorial for making a speedometer at:
http://answers.unity3d.com/questions/8120/how-can-i-make-an-on-screen-speedometer
It basically converts the velocity of the rigidbody into a MPH reading. Had to make a few changes though, since the MPH were being printed out as a float and not an integer. To solve this, i added the parseInt() method to the MPH reading to convert it into an integer value. The code is below.
var mph = parseInt(rigidbody.velocity.magnitude * 2.237);
mphDisplay.text = mph + " MPH";
If I have time an the end, I would like to go make and make a needle based speedometer, but is it not the most important thing to impliment at the moment.
No comments:
Post a Comment