Hey I’m new to unity and I need some help on something. In my game the player can click on a piece of paper and see what’s on it how would I achieve this? At help would be appreciated.
I’ve had the most success with attaching a script to the paper that stores the text and using a raycast on the paper object.
public string CheckForText(){
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if (Physics.Raycast(ray, out hit, 100)) {
TextHolder textHolder = hit.collider.gameobject.GetComponent< TextHolder>();
if(textHolder != null) return textHolder.text;
}
return "";
}
If the string returned is empty, then that would tell whatever script you’re using not to display it.
Thank you I found out a way to do it your script helped me a lot thanks.