public class ScalingManager : MonoBehaviour
private List positions = new List();
// Start is called before the first frame update
var ObjectsToScale = GameObject.FindGameObjectsWithTag("Scaling Object");
// Scale amount of the prefab before - 0.5F
// For example : The scale amount of the prefab before is 10
// So the end scaling position is 10 - 0.5f = 9.5f
// So the next prefab should start scaling at position
// new Vector3(scale amount - 9.5f, objecttoscale.transform.y ,objecttoscale.transform.z );
for(int i = 0; i < ObjectsToScale.Length; i++)
for (int i = 1; i < positions.Count; i++)
ObjectsToScale(i).transform.localPosition = new Vector3(
ObjectsToScale(i - 1).transform.localPosition.x, 0, 0);
// Update is called once per frame
The first object to scale in the original position of the array is in this case 0,0,0 but it could be any position, for example 11,22, -5 but in this case it is 0,0,0
The second object to scale the original position is 12.4, 0.5, -7.39
Both objects are scaled at the same time when the game is run. The first is scaled in the correct direction, the second is scaled in the downward direction.
This is a screenshot of the first object to scale the inspector settings. The start position is 0,0,0 and the red circle shows the position of the final scale on the right:
The second screenshot showing the second object to scale information:
And the last screenshot is what I want to do. I want the second object to scale to start scaling, the position will be where the red circle is in the first screenshot. Therefore, each object to scale if there will be 20 objects to scale each object to scale should start scaling from the final scaling position of the object to be scaled earlier in the array.
So it must start from the second: ObjectsToScale1 put it in the red circle at the end position of ObjectsToScale (0)
Then ObjectsToScale2 must be placed at the end scale position of ObjectsToScale1.
I like this :
The upper red circle shows where ObjectsToScale (0) ends and ObjectsToScale1 begins. The lower red circle shows where ObjectsToScale1 ends and ObjectsToScale2 begins.
ObjectsToScale2 is scaling to the left.
Right, down, left
So if I have 3 objects to scale and set them to scale: Right, Down, Left, no matter what the starting position of each is, it should create the last screenshot form.
The same idea if I have 7 objects to scale: Left, Down, Right, Up, Right, Down, Down. Connect them all from the end of the previous one.