What I am trying to do is add a group of objects along a straight line using a “tween” animation, so that the objects are grouped around the middle of the line, then another group is added to the previous group, so the previous group is shifted to the left to form a new group whose elements are grouped around the middle of the straight line.
![
]

In short: I'm trying to do what the hbox container does when we set the alignment mode to center and set a certain value for separation, but in 3D with respect to the x coordinates of the object.

All I need to know is the mathematical equation used by the hbox container, taking into account the settings previously mentioned, or something like that

Parameters:

  • t: the total available width
  • x: the width of a box (assuming they all have the same width, otherwise it gets complicated)
  • s: separation
  • n: number of boxes
  • i: index of the box (stating from left, and starting at 0)

Then the x coordinate of box i is: (t - n*x - (n-1)*s)/2 + i*(x+s)

    Zini

    I have two problems:

    The first is that I want to set a specific midpoint so that it is the middle of the group of objects. I know that it is the middle of the distance between the start point and the end point, but it did not give the midpoint that I wanted.

    The second problem is that I noticed that when I add a new group consisting of two objects, their order is reversed

    I forgot to mention that I use the tween in the "for" loop for the number of objects to be added