I down loaded a car physic asset that has the MPH displayed on the game screen which works great. Would like to add a “Top MPH” display to the game screen. I copied and pasted the line of script that displays the “MPH”. I edited the position and the text, but I am not sure how to display just the top speed. Would like it to count up the MPH as the car goes faster, but hold the top speed when the car slows down. I am new to this and have worked on it for a couple of weeks with no successes. Below is the block of code for the displays and a screen shot of the displays.
Thanks,
Todd
void OnGUI()
{
//show the GUI for the speed and gear we are on.
GUI.Box(new Rect(10,10,70,30),"MPH: " + Mathf.Round(GetComponent<Rigidbody>().velocity.magnitude * 2.23693629f));
//Copied and pasted the above line and changed the position and text.
GUI.Box(new Rect(700,10,110,30),"TOP MPH: " + Mathf.Round(GetComponent<Rigidbody>().velocity.magnitude * 2.23693629f));
if (!reversing)
GUI.Box(new Rect(10,70,70,30),"Gear: " + (gear+1));
if (reversing)//if the car is going backwards display the gear as R
GUI.Box(new Rect(10,70,70,30),"Gear: R");
}
