- Home /
Instantiating GUI text after 2nd object is destroyed
When the player first triggers the crate object, a fuelcell object is instantiated. When the player selects the fuelcell, what should occur is a gui.text to replace this fuelcell with a "-5" for instance. This however is not occuring. I've tried the following:
1) added the guitext gameobject to the crate object and once the fuelcell is null tried to instantiate the guitext object.
2) instead of adding to the crate object, i am trying to figure out a way to add to the player so that once the fuelcell is selected, the pop up will occur.
I am basically trying to achieve the effect seen at 1:53 of http://www.youtube.com/watch?v=JEmUOU1ksi8 where there are gui text objects popping up.
Answer by aldonaletto · Jul 18, 2011 at 04:26 AM
You can instantiate a GUIText prefab which will move up and vanish slowly, and destroy itself when completely invisible. I wrote such a script some time ago, and you can find it in the question Attack Damage Scrolling. It's a step-by-step guide on how to create that "flying text" effect, exactly like the game you've mentioned. You just have to create the prefab and instantiate it when needed - the text "suicide" itself when become invisible.