|
Further to my previous question about showing/hiding guiText, i'm working on a closed caption system where a caption will show when the player comes within range of a sound. I'm using a guiTexture to create the black background, and guiText for the caption String. Most sounds in the environment are continuous, so they should show a caption all the while the player is in range, then hide the caption if not. However, a couple of sounds are one-shot played by animation events so I want these to show for a period of time specified by me. I previously got a system working that would hide captions after a specified time, but as described above, this isn't exactly what I want. In trying to amend my code to hide captions if the player moves out of range, I've discovered that now only the one-shot events seem to show up reliably. I believe the reason being is that i'm using one guiText and guiTexture for the one-shot events, and another pair for the general sound effects. Since the general sound effects call the function from Update(), I think they are overriding each other. Due to this problem, i'm not even sure if my revised IF statement is doing what I want it to now. Also, I'm thinking, rather than creating pairs of guiText/guiTexture for each caption, a better approach is to instantiate them. I know that they will require screen co-ordinates (in my case i'm using x 0.5 and y 0.2), but how would I use this with Object.Instantiate? Here is my current code:
(comments are locked)
|
|
You instantiate them the same way as anything else: Thanks Eric, I wasn't sure about the last parameter. Instantiating works fine now, but I need to get my head around destroying the object. I'm finding it more complicated since the above script is not on the caption guiText itself. I may just go ahead with my older script for the time being since i'm on a deadline.
Apr 16 '10 at 11:07 PM
straydogstrut
@straydogstrut: To destroy an instantiated object, do
Apr 17 '10 at 12:36 AM
Eric5h5
(comments are locked)
|
