(C#) How can I toggle "Simulated" in a Rigidbody2D?

on a gameObject with several children, all of which have a Rigidbody2D component, I want to enable (or disable) the “Simulated” property on the Rigidbody2D, using:


I get the error:
Type UnityEngine.Rigidbody2D[]' does not contain a definition for simulated’ and no extension method simulated' of type UnityEngine.Rigidbody2D[]’ could be found. Are you missing an assembly reference?

what am I doing wrong? Thanks for reading!

You are trying to call an instance function on an array.

A concrete example of this would be if you had an Apple object with a Bite() function. You’re effectively trying to call the Bite() function on not one apple, but a sack of them. Which confuses the compiler.

Instead, you need to loop through the array that is returned, and apply your logic to each instance within.