- Home /
Question by
hraklism1991 · Jul 09, 2019 at 06:56 PM ·
raycastraycasthithit
Unity | Raycast Hit Empty Object which has Objects as Children
I Have an Empty Object with no collider which has children that are 'proper objects' with colliders and meshes etc...
When I click on the Object and do:
RaycastHit hit;
Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit);
hit.collider is Null (of course).
My question is, how can I get the Empty Object on hit?
Is there a way or I should apply a mesh collider on the Empty Object?
If yes, how can I do that?
P.S New to Unity
Comment
Answer by Magso · Jul 09, 2019 at 07:11 PM
The objects are children so you can use hit.transform.parent
to reference the empty object.