Sign Script!

I am currently working on a script that would display a GUI label or tooltip when the mouse hovers over the sign name, but i have no idea where to start. any suggestions? i already have the model and stuff…

What you want to do is cast a ray forward from the position of your crosshair, and get the information of the object it hit. Here is a little pseudo code to get you started.

var screenLabel : GUIText;

function Update () {
	var hit : RaycastHit;
       //Cast a ray from the center of the screen
	var ray : Ray = camera.main.ViewportPointToRay (Vector3(0.5,0.5,0));
	if (Physics.Raycast (ray, hit, 300)) {
	    var hitObject : GameObject = hit.transform.gameObject;
	    screenLabel.text = hitObject.name;
	}
}

thanks! Would you mind exlaining “raycasts” to me? ive coded in unity alot but never ran into rayscasts. >.<

It didnt exactly work… I dont want it to stay on the screen just show up when you hover the cursor over it

Here is a nice little writeup on Raycasts.

As far as the other issue, I could write the code for you, but consider this an exercise in coding. If the ray that is cast does not hit something, you want to set the GUIText Object’s text to a blank string. Just a few lines of code are needed, and I think you can figure it out.