- Home /
Need to increase position of multiple prefabs by the same number
Hey guys, I’ve made large 3D hex map in unity however the hexes where slightly bigger than the tile map and I need to increase the position of each hex by a certain number. Is there are way of doing this with a script, build-in feature, etc. or do I have to go through and manually change the value of each object (PS I have around a 100x100 map of objects that need to be changed)
Thanks in advance
Untested pseudo code inco$$anonymous$$g, though you might be able to do something like:
function Start()
{
var _refTransform = GameObject.FindObjectsWithTag("Tile").transform;
foreach (Transform t in _refTransform)
{
t.position = t.position + new Vector3(1, 1, 1);
}
}
the code above is kind of ugly and is definitely untested, though you might be able to do something like that, just loop through each object at the start and update it's position... Depending on the amount of objects you have, that method could be incredibly slow. If you can I'd recommend just moving all of the objects within your scene manually.