Hi, I’m having a bit of a headache here trying to create a formula that will put these cubes together after I scaled them to 0.5f. This is in C#, by the way.
As you see:
After scaling them down, they lost their main position. So, I need to increase/decrease the position (depending on the direction left or right) by 0.5f (minus or plus).
Here is the code:
/* Dirt */
for (int y = 0; y < 15; y++)
{
for (int x = 0; x < 15; x++)
{
GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
cube.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f);
cube.renderer.material.mainTexture = dirt;
cube.transform.position = transform.position - new Vector3(x, 0, y);
}
}
The reason I can’t really change the position of a cube and expect it to move is because it is in a loop, so all the cubes at the same time will go to the position you try and set in the new Vector3. All I want to do is put those blocks closer together! Any help is appreciated, this is giving a headache.