Is there a way of correctly parenting to get scales and positions of gameObjects right?

Originally, I was doing this:

void Update ()
{
    this.transform.position = new Vector3 (previousObject.transform.position.x + prevRend.bounds.size.x / 2 + rend.bounds.size.x / 2, this.transform.position.y, this.transform.position.z);
    //the position of both gameObjects should be aligned when one or both of their scales change
}

But because gameObjects didn´t update their positions fast enough (caused gaps for small amounts of time), I thought maybe making something different. So I commented the rest of my doings earlier, which is basically changing the scale of a parent object based on a percentage to make its children do the same. Their positions changed automatically, avoiding the gaps that I had. Also this works with the correct proportions for every gameObject and even the positions are right… when including everything.
I wanted to increase or decrease size of some of this gameObjects independently to the others, but when these are out of the parent the positions are not aligned anymore. Is there some way of correctly parenting them and get both things right?

there are two ways of doing this:

  • keep your objects children and by the time they should be locked to their scale, save the parent scale and keep multiplying the local scale by saved scale divided by current parent scale, which will counter scale the object and therefore keep it’s size (works with just one parent that’s changing scale only)
  • unparent the children by the time they should be locked to their scale, but save their local position beforehand. now you can use parent.TransformPosition(savedLocalPosition) to get the scaled position you can set the childs position to. since not parented, it will keep it’s size but move relative to the parent through scale.

I recommend the second option

OK, so actually a better solution was just to use InvokeRepeating () to update the position faster avoiding gaps. Nothing related to parenting.