- Home /
HELP with scripting where GUI is involved
I have a section of code set up which is making the text appear, but it is appearing as soon as i press play rather than when the animation is triggered, hoping someone can help me sort this problem out, ill post my code below.
Thanks in advance for any help offered.
displayMessage = false;
function OnTriggerEnter (Player : Collider) { animation.Play("Take 001"); displayMessage = true; yield WaitForSeconds(3); displayMessage = false; }
function OnGUI ( ) { if ( "displayMessage" ) { GUI.Label(new Rect(Screen.width /2.5, Screen.height / 2, 200, 200), "You received 5gp"); } }
Just my 2 cents... You should learn scripting if you really want to pursue this... Obviously, if this is for a school project, then you should be trying to LEARN something, rather than script kiddy'ing all day and having people do your whole project for you... If you don't want to make a game, then don't make a game... If you want to take the time to learn to make a game, than take the time... What you're asking is a very stupid and ignorant question that anyone with any brain of program$$anonymous$$g knowledge could answer...
Answer by Joshua · Apr 15, 2011 at 12:58 AM
At the top where you say:
displayMessage = false;
it should say:
var displayMessage = false;
and whereit says:
if ( "displayMessage" )
it should just say:
if (displayMessage)
is there any way to change the size etc of the text that appears on screen? is that done in the code?
Travis, this site is for helping unity developers when they have a real question, not for asking questions that have already been answered http://answers.unity3d.com/search?q=gui+text+size and are easy to look up http://unity3d.com/support/documentation/Components/GUI%20Scripting%20Guide.html
Answer by marceloroca · Apr 15, 2011 at 12:49 AM
change if ( "displayMessage" ) to if ( displayMessage )
ok thanks ive just tried that when i did it though this error occurred.
Assets/NewBehaviourScript.js(13,14): BCE0005: $$anonymous$$ identifier: 'display$$anonymous$$essage'.
Your answer
Follow this Question
Related Questions
How do i make a text box appear on screen after a chest has been opened? 3 Answers
Fix Blurry UI text? 10 Answers
Create GUIText from Javascript 3 Answers
Gui text, ammo counter 1 Answer