|
Hi, ive made a chest animation triggered when a player reaches the chest that it opens up, i now want to make it so once this animation is triggered a text box will appear saying what you received out of the chest. How do i go about doing this? This is the script i already have in place incase it is needed.
(comments are locked)
|
|
Hi, If you want to draw something on GUI, you can use the OnGUI method for GUI drawing. see if this sample helps (someone help to port it to JS for him?) : This'd be perfect... Better than mine. 1 problem, displayMessage never becomes true... So in the OnTriggerEnter, make it true, then put in the yield, and make it false again after a certain amount of time. Nice Danilo!
Apr 14 '11 at 10:16 PM
Justin Warner
You have to set displayMessage = true on the OnTriggerEnter method. I forgot that =/
Apr 14 '11 at 10:18 PM
Danilo Nishimura
Can i use this as a boo script or should i try n keep all my scripts in java? thanks for the help guys
Apr 14 '11 at 10:29 PM
Christopher Travis
I think the result is the same as it's compiled to an intermediate language before the final compilation. I recommend you to write all your scripts in the same language to maintain a coding pattern and you won't get confused about which language to use when writing new files. Even if you get a sample code from somewhere, I recommend to rewrite it.
Apr 15 '11 at 02:04 PM
Danilo Nishimura
(comments are locked)
|
|
Make this a seperate script on the same object...
Then....
Check out how to use GetComponent: http://unity3d.com/support/documentation/ScriptReference/Component.GetComponent.html Good luck! TO _ JAVA displayMessage = false;
Ignore mine, use his, but this can work I think... Not the best when not on my computer. thanks for that conversion. ive copied over the code, but it is coming up with this problem, Assets/NewBehaviourScript.js(5,43): BCE0044: expecting :, found ';'. i dont know how to solve this one, should one of the lines have a colon instead of semicolon?
Apr 14 '11 at 11:32 PM
Christopher Travis
ive posted sumthin i hope u can help with as an answer below so its easier to see
Apr 15 '11 at 12:31 AM
Christopher Travis
(comments are locked)
|
|
I had the problem i mentioned in the comments above with the code you supplied, so i made a few alterations so there were no errors and i could get in play mode, but now the text just appears from the start and doesnt dissapear rather than appearing when the animation is triggered. heres the new code ive had to use so it said there were no errors. changes i had to make were,
it didnt like the extra { at the end because it wasnt attached to anything, when i tried just adding another one of them at the end it caused more errors. ALSO
im guessing these changes are the reason it doesnt appear at the right time but it was the only way to remove the errors. Is there any help you can give to correct this so it appears at the right time when the animation is triggered? Thanks My bad with the bracket, however displayMessage is actually a String you're to initialize before you actually run the function. And what's wrong now? Does it not work?
Apr 15 '11 at 01:35 AM
Justin Warner
(comments are locked)
|
