Hi,
I already tried a few codes but somehow it does not work. I have a a few boxes in scene and if the camera is looking at them, some text should be send to a gui text object. The raycast is working now and i can debug the name of the object, but not send it to the text object “infotext”. Can you tell me wich code i have to add here?
here my raycast code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class raycast_findTriggers : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
RaycastHit hit;
if (Physics.Raycast(transform.position,transform.forward, out hit,100))
{
Debug.Log(hit.transform.name);
// HERE I WANT TO SEND THE NAME OF THE OBJECT TO THE TEXTOBJECT called infotext.
}
}
}