- Home /
Gui Text Script
Hi,
I'm doing the challenge 3 on http://www.unity3dstudent.com/2010/07/challenge-c03-beginner/ and I can't get the GUI Text to work. I what the GUI Text to go up by one number every time the ball collides with the box/target, and when you get 3 point go to the win screen. What script (Javascript) do I need for that. Thanks,
Mr.Snake
hrm... how the hell did this get 11 votes and 11 faves? 3 funky llamas and emailing scripts?... though the content is not offensive per se, I feel very much like closing this for cheating the system so ruthlessly... bumping this useless stuff to page 4 of 'most voted'... not appreciated.
Greetz, $$anonymous$$y.
Answer by funkyllama 2 · Oct 28, 2010 at 06:35 PM
Hi,
As promised I've emailed you the complete project. Sent to email found through the website link found on your profile ;)
Answer by funkyllama 1 · Oct 27, 2010 at 02:06 AM
Hi Mr Snake When I next get on my dev computer I'll comment the code and send you the project ;) PS. Don't forget to vote me up :)
Answer by funkyllama · Oct 26, 2010 at 06:14 PM
How I done it..
Created a script named score.js with the following code:
static var Score : int = 0;
function Update () { this.text = "Score:" + Score.ToString(); if(Score == 3) { Application.LoadLevel("youwin") } }
I attached this script to the GUItext object that displayed the score.
Then in the script that catches collision with the box I put
score.Score += 1;
Hope this helps ;)
Sorry, I am the noob of all noobs. I'm not sure what the "script that catches collision with the box" is supposed to look like, could you include the hole script? Thanks!
@$$anonymous$$rSnake. You would increment the score in the collision event:
function OnCollisionEnter(collision : Collision) { score.Score += 1; }
Answer by funkyllama · Oct 27, 2010 at 02:08 AM
Hi Mr Snake When I next get on my dev computer I'll comment the code and send you the project ;) PS. Don't forget to vote me up :)
Your answer
Follow this Question
Related Questions
Create GUIText from Javascript 3 Answers
How to change the text on an other object ? 2 Answers
How to make GUI Text appear after a certain amount of time 2 Answers
Changing 3d text through script 1 Answer