void SetObjectKinematic(TrapElement obj, bool isKinematic) { foreach (Rigidbody r in obj.GetComponentsInChildren <Rigidbody>()) { r.isKinematic = isKinematic; } BoxCollider box = obj.gameObject.AddComponent <BoxCollider>(); box.isTrigger = isKinematic; }