Moving object relative to another objects axis

Hi, im having a hard time figuring out how to make object “last” be all the time right behind places[0] object. The script is not working how i’d like it to work.

It stays 2 units behind in world space z axis and i want it to be behind 2 units in places[0] z local axis.

Basically i don’t want this to happen(“last” object is the one which is not in the row and places[0] object which is last cube in the row):

`last.transform.position = new Vector3(places[0].transform.position.x , places[0].transform.position.y , places[0].transform.position.z - 2`);

I’m not really understanding but it sounds like you want to make “last” a child of places[0].

if for some reason you dont want to do that than use localPosition:

`last.transform.position = new Vector3(places[0].transform.localPosition.x , places[0].transform.localPosition.y , places[0].transform.localPosition.z - 2`);

If you thought to do that, you understand the question. I tried all of that already. If i make last a child, then it still does the same thing and nothing changes for some weird reason. If i use local position, it still doesn’t work. “last” is just a lot more away (not 2 units) and its not in the same direction,


0:53 - Notice how second row stays alinged to first row? I want to achieve that.