- Home /
Displaying Level
Hey,
I'm working on a space shooter game and so far I have 10 different levels and instead of changing the background I want to display the level you're currently on. Right now to change levels you have to reach a certain score. Basically I have a bunch of if statements in the playerScript that ask if the playerScore == a certain number, and when it does change the level and add a little bonus.
So the question I have is how i should go about displaying the level you're on and how to make that work with the setup I have. I'm new to javascript so any suggestions on how to set it up better would also be helpful.
Thanks.
Answer by testure · Jun 18, 2011 at 05:58 AM
drop a guiText gameobject in your scene.. give it a useful name like "LevelText" or something, and then in your script, just:
GameObject.Find("LevelText").GetComponent<GUIText>().text = "The Current Level is " + levelnumber;
That's C#, but it should be pretty similar in JS (you probably don't have to cast the getcomponent call to a GUIText, for example.. but i don't use JS so i couldn't say for sure. good luck :)
Awesome thank you! Can anyone translate that to javascript for me? Also, what do you mean guiText gameobject?
Your answer
