RaycastHit.transform/collider

When I use RaycastHit.transform I get the grandparent of the collider the ray hit and when I use RaycastHit.collider I get the collider of the GO that my ray hit.
Can someone explain why sometimes it works and sometimes it’s something alse?

I think RaycastHit.transform looks for a rigidbody, so if the grandparent of the collider is the gameobject that has the rigidbody component on it then that is what will be returned. If you use RaycastHit.collider.transform you should get what you are after.

I just ran into the same issue. Its really badly explained in the Unity documentation and should probably be called RaycastHit.rigidbidy or something.

Hope this helps,
Peter