IRaycastable components on children with Ridigbody parents

I’ve noticed that RaycastAll will not detect raycastable components if it is attached to a child with a parent that has a rigidbody. Is there any way to work around this without unchilding the object or removing the rigidbody?

I realize now the answer is obviously to change
IRaycastable[] raycastables = hit.transform.GetComponents<IRaycastable>();
to
IRaycastable[] raycastables = hit.transform.GetComponentsInChildren<IRaycastable>();

That is correctly. GetComponents only looks on the specific GameObject.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.