public void LoseStrengthChildren(float loseStrength, Transform ignoreChild = null) { loseStrength *= strengthLoseFalloff; foreach (Transform item in transform) { if (ignoreChild != item) { RagdollBodyPart child = item.GetComponent <RagdollBodyPart>(); if (child) { child.LoseStrength(loseStrength); child.LoseStrengthChildren(loseStrength); } } } }
public void LoseStrengthParents(float loseStrength, Transform currentTransform) { RagdollBodyPart parentScript = currentTransform.parent.GetComponent <RagdollBodyPart>(); if (!parentScript) { return; } parentScript.LoseStrength(loseStrength); loseStrength *= strengthLoseFalloff; parentScript.LoseStrengthChildren(loseStrength, currentTransform); LoseStrengthParents(loseStrength, currentTransform.parent); }