- Home /
Teach me Label, speech bubble, overlay text, pop up box, etc
I need help..can someone teach me on how to do this, I've try look into unity and unity answer but still cannot understand the basic principale of doing this all type of dailog box.
and I try to find a tutorial about this, cannot find it anywhere..can someone point me to the right direction..
thank you..
Answer by Adrian Love · Jun 15, 2010 at 03:56 AM
If you're having trouble with this I'd suggest reading through the lerpz tutorial. http://unity3d.com/support/resources/tutorials/3d-platform-game
What you could do is perhaps expand on the functionality of the lerpz game with a speech bubble dialog box.
Specifically for GUI dialog boxes I'd look at: http://unity3d.com/support/documentation/Components/GUI%20Scripting%20Guide.html
Good luck and welcome to unity.
Answer by hizral84 · Jun 16, 2010 at 02:32 AM
okay..here's my code:
var target : GameObject;
function Start() { target.renderer.enabled = false; }
function OnTriggerEnter(hit : Collider) { if (hit.gameObject.tag == "Player") { target.renderer.enabled = true; print("ENABLED"); } else { target.renderer.enabled = false; print("DISABLE"); }
}
the code sort of work, when my Player is far away from the object the label is hide, and when I approch the object the label will hover above the object..but right now when my Player walk away from the object the label is still there and did not hide at all...
Answer by Tetrad · Jun 16, 2010 at 04:17 AM
In response to http://answers.unity3d.com/questions/12451/teach-me-label-speech-bubble-overlay-text-pop-up-box-etc/12556#12556
Your logic for entering/exiting is wrong. You're basically checking to see if something other than the player entered the trigger, and if so to turn it off. You want something like this
function OnTriggerEnter( hit : Collider ) { if( hit.gameObject.tag == "Player" ) { // enable } }
function OnTriggerExit( hit : Collider ) { if( hit.gameObject.tag == "Player" ) { // disable } }
thanks, it help alot.
but still sorry if I ask this question, can we still contain everything in one trigger.
That is in one trigger. When you enter the trigger it turns on, when you exit it turns off.
Answer by TheGeekyDead · Mar 25, 2014 at 04:18 PM
@ hizral84
It's because you only have an on trigger enter, and no exit lol. Maybe to late to help but it might help someone else idk.
I tested it works great, after i added exit to it.
var target : GameObject;
function Start()
{
target.renderer.enabled = false;
}
function OnTriggerEnter(hit : Collider)
{
if (hit.gameObject.tag == "Player")
{
target.renderer.enabled = true;
print("ENABLED");
}
else
{
//target.renderer.enabled = false;
//print("DISABLE");
}
}
function OnTriggerExit (hit : Collider)
{
target.renderer.enabled = false;
print("DISABLE");
}
Your answer
![](https://koobas.hobune.stream/wayback/20220613062137im_/https://answers.unity.com/themes/thub/images/avi.jpg)