How do i make a raycast sign text? Answers Appreciated

Hi there, im struggling to find an answer for a script that can display text when i press E. For example:

If i look at a sign and press E i want it to display some text (a string variable using public string SignText;)

All the other answers are to do with doors and stuff i dont care about.
Please help :slight_smile:
All answers are greatly appreciated
-Nelawyth

This is how I have done mine, which sounds like its similar to what you’re looking for.
Attach this to your Camera, and make sure you have a canvas and a text component and set the tags correctly, or just tweak it to your preferences. And add this to the top (without quotation marks) “using UnityEngine.UI;”

{
    	public float InteractDistance = 2.75f;
    	Text HighlitedName;
    	RaycastHit Hit;
    	void Start()
    	{
    		HighlitedName = GameObject.Find("CanvasText").GetComponent<Text>();
    	}
    	void Update()
    	{
    		HighlitedName.text = null;
    		if (Physics.Raycast(transform.position, transform.TransformDirection(Vector3.forward),out Hit, InteractDistance))
    		{
    			if (Hit.collider.tag.Equals("Interactable"))
    			{
    				HighlitedName.text = (Hit.collider.name);
    			}
    		}
    	}
    }

@CarbonNanoRob Could you fix the code so i can use the public string SignText;
to display text, Im having trouble modifying the code

-Nelawyth