Game Development Reference
In-Depth Information
Tracking stats
Now we will add the stat tracking feature that we created in Chapter 6 , Keeping Score .
Adding the script
To allow stat tracking, we will simply drag the StatTracker script and drop it on the
main camera. Now, to show the menu for stats, we will need to add an Update func-
tion. Add this to your script:
void Update()
{
if(Input.GetKeyUp(KeyCode.E))
{
if(showStats)
showStats = false;
else
showStats = true;
}
}
Now when the player presses the E key, it will toggle the showStats Boolean vari-
able. The stats menu will only show when showStats is set to true .
Search WWH ::




Custom Search