I have a horizontal list of gameobjects in my scene. I want these objects to each have the same amount of distance between them along the X axis when the game is playing no matter how and where they are dragged to in the scene. Right now i entered this code to the gameobjects to have the y positions set to 0:
transform.position.y = 0;
But what i would like to do is drag each gameobject into the scene and then the code would position the objects in a horizontal line along the X axis but each with the same distance between them.
eg. object1 would be at (0,0), object2 at (2,0), object3 at (4,0), and so on, and this will all be done automatically through code.
I have already added the gameobjects to the scene, and i’m just wondering is this can be done?
This is a 2D game.
Any help would be deeply appreciated.