So i created a raycast that “shoots” from the center of the camera and i want to know to do make a little text (object’s name) appear on the screen when i hits an object.
So here i started the code but i don’t know how to make it:
The second part depends on the answers to other questions. For example, do you want this text to be in screen space (e.g. part of the UI, just hovering in position of the hit) or in world space (actually rendering as a part of the world)? Also, is this functionality something you expect to use often, because if so, it may be worth generalizing it.
If it is for debugging, make a Unity UI Text field, drag a reference to it into your screen, and put the information you want in the .text property at the right time.
If it is “for reals,” look into putting Unity UI Text objects into the scene (requires some canvas setup and parenting to make it stay close to where you want) and then do the same setting of the .text property.