I am making a game and i need to have the player see that they can interact with the object, i have a raycast set up to work with a few objects and the other things but i need them to be able to hover over an intractable object and tell them they can interact with it. If anyone could help that would be amazing!
You can create a text in your canvas and access it as a GameObject.
To detect if your player is in contact with the objects, use a triggered box collider so your player wont be blocked by it and Unity will detect the collision.
ex:
GameObject text;
void OnTriggerEnter ()
{
text.setActive(true);
text.GetComponent<Text>().text = "press E to use";
}
void OnTriggerStay ()
{
if (Input.GetKeyDown(Keycode.E)
{
Debug.Log("interaction");
}
}
void OnTriggerExit ()
{
text.setActive(false);
text.GetComponent<Text>().text = "";
}