In the waypoints script, I have a static variable names NoLaps. This is the variable I am using to count the number of laps the players has driven round the course. In order to print this onto the screen, I need to introduce a GUIText into the scene.
After adding the GUIText, I needed to edit a few parts of the Waypoints script to print the variable 'NoLaps' to the GUIText. The first thing to do was to add a new variable.
var lapDisplay : GUIText;This sets up a variable of type GUIText. Then I needed to create an update method and add a line of code to pass this new GUIText variable the interger value of the 'NoLaps' variable.
function Update () {
lapDisplay.text ="Lap " + NoLaps + "/5";
}
This line is pretty much self explanatory. It passes the NoLaps variable as well as some useful HUD text to the text component of the GUIText variable. All that is left is to Assign the GUIText game object to the lapDisplay variable in the script.
No comments:
Post a Comment