Hello all! I am trying to scale specific parts of a 2D character and have all of the child objects scale and position themselves accordingly.
The scaling works fine but when I try to reposition the child to be where it should reletively be I get the exception
UnityException: Transform child out of bounds
First I’m wondering what the exception is and second how it is thrown.
Here is my code
private void BoneScale()
{
Transform[] tempBone = knight.mBoneTransforms;
foreach (Transform gameObj in tempBone)
{
if (gameObj.parent != null)
{ //Look for specific bone
if (gameObj.parent.name == "Arm L")
{
//Set its new scale
gameObj.localScale = new Vector3 (10, 10, 1);
//Get the childs Transform
Transform tempTransform = gameObj.GetChild(0);
//Get the childs position
Vector3 tempPosition = tempTransform.position;
//Set the new positon (I used a low number to test to see if would bypass the exception, nope
tempTransform.position = new Vector3(tempPosition.x + 1, tempPosition.y + 1, tempPosition.z);
}
}
}
}
Any help would be appreciated