Knowing when a Childobject is hit by Raycast
I have Created a Scene where it's possible to track the eyemovement of the user in VR. Since I want to know if the user is actually looking at specific objects in the Scene, I wanted to use the camera Raycast. That's the script I wrote
private void GetHitbyGaze()
{
RaycastHit hit;
if (SMI.SMIEyeTrackingUnity.Instance.smi_GetRaycastHitFromGaze(out hit))
{
if (hit.collider.gameObject.GetComponent<Hit>() != null)
{
hit.collider.gameObject.GetComponent<Hit>().GotHit();
Debug.Log("1");
}
else
{
Debug.Log("0");
}
}
}
The Problem I have is that I want to attach this script to a parent Object, so that I don't have to attach it to every Object that I want to have the hit information about. Is there a way to get the Information if a child object is hit by the Raycast?
If somebody could help me, I would really appreciate it!
Your answer
Follow this Question
Related Questions
How can I correctly generate Button objects with C# script? 1 Answer
How to play games from VR samples with Keyboard and Mouse 0 Answers
pressing/turning something in VR to do stuff 0 Answers
Making KeyCodes Equal to Touch Triggers? 1 Answer
Camera Follow Script destroys Raycast on VR-Hands with Late Update 1 Answer