While the Parent expands, the children get smaller. Problem

Hello. I am using a script that when a mouse clicks goes off a certain object all objects linked to the same parent will expand. The parent and the objects do get bigger in a way I’d like. For some reason however, the objects inside the parent ( Empty game object ) get smaller and smaller as you progress into the game. How can this be fixed? This is the script

using UnityEngine;
using System.Collections;

public class Expand : MonoBehaviour {
	public Transform parent;
	public float expandAmount = 2f;

	void OnMouseDown()

		parent.localScale *=expandAmount;
		for(int i =0;i<parent.childCount;i++)
			parent.GetChild(i).localScale = parent.GetChild(i).localScale/expandAmount;

If clarification on anything is needed, just ask. Thanks

They get smaller because you are dividing( / ) by the expand amount. if you want them to expand by a factor of 2 you need to multiply( * ) by the expand amount.

If i understand you correctly, you want the childs of the parent to increase equally in size right?
Then you should also use the ∗ operator inside the for loop to multiply by the expand ammount instead of /.
BTW: You can also set the child size with ∗= or /= as you did with the parent.

Since i’m not allowed to post a reply:
I don’t know if the parent will affect the childrens scale or if they just get bigger without any values changing.

Save the scale/size of the child as a variable (vector3) before changing the parents scale. You can then set the scale back to the original size with the saved variable.