How to tell if a looked at object has a text mesh.
I'm creating a VR where when you look at an object text display showing info on the object. I creating a script that uses a ray cast to tell when an object is looked at. Is there a way to get tell if the object that is looked at has a text mesh that becomes active if it is looked at. The script is unfinished so if you can help finish it it would be help me a lot and you will get a reward.
private RaycastHit lastRaycastHit;
// Use this for initialization
void Start () {
Cursor.visible = false;
Text = GetComponentsInChildren<MeshRenderer> ();
}
private GameObject GetLookedAtObject(){
Vector3 origin = transform.position;
Vector3 direction = Camera.main.transform.forward;
float range = 1000;
if (Physics.Raycast (origin, direction, out lastRaycastHit, range))
return lastRaycastHit.collider.gameObject;
else
return null;
}
void LoadScene () {
Application.LoadLevel ("MineHD");
}
void Update () {
if (GetLookedAtObject)
}
}
Comment
Your answer
Follow this Question
Related Questions
Activate Button only by looking at it? 0 Answers
Oculus VR camera spins out of control 0 Answers
How to resolve object overlap in vr mode? 1 Answer
How do I offset a camera when it's position is defined by a VR controller 0 Answers
SteamVR Plugin and 3D-technology don't work with each other 0 Answers