how to access rigidbody2D in childrens

Hi, how can I access rigidbody2D or other components in children, what I have tried is this code

`
public Rigidbody2D myRigidbody2D;

myRigidbody2D = GetComponentInChildren as Rigidbody2D;
myRigidbody2D.isKinematic = true;
`

and other codes but none of them is working

Hope someone can help me

Thanks,

To access components in children try this:

myRigidbody2D = GetComponentsInChildren<Rigidbody2D>()

And to make all of the rigidbodies in your array Kinematic you need to sort through them so:

foreach (Rigidbody2D rb in myRigidbody2D) { rb.isKinematic = true; }

Hope that helps!