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.
All answers are greatly appreciated
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;
HighlitedName = GameObject.Find("CanvasText").GetComponent<Text>();
HighlitedName.text = null;
if (Physics.Raycast(transform.position, transform.TransformDirection(Vector3.forward),out Hit, InteractDistance))
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