question regarding rigidbody collider interactions!

I currently have a game with a spaceship building system that resembles Minecraft’s block placing. All connected objects are placed under one root “Ship” game object. the problem I am running into is that, to access raycast hit data about a child game object that child must have a rigidbody(I set it to kinematic). this however seems to not let the root object use child colliders resulting in it phasing through other colliders.

I run into other issues when rigidbodys are removed from the children so I would like to keep them but if that’s not possible any advice would be great!

Rigidbodies are not required to get information about hits, a collider is enough. You get access to the Transform of an object hit through the RaycastHit, the Transform gives you access to all children.

Read:

Physics.Raycast - “Returns true if the ray intersects with a Collider, otherwise false.”

Transform.GetChild - “Returns a transform child by index.”

RaycastHit.transform - “The Transform of the [rigidbody or] collider that was hit.”

Example:

//RaycastHit hit
GameObject child = hit.transform.GetChild(0).gameObject; //first child of the gameobject hit
Transform childTransform = hit.transform.GetChild(0); //transform if the first child of the gameobject hit