Need help making a small script.
needs to move all objects with name track***
to world position y = -5
many thanks!
Need help making a small script.
needs to move all objects with name track***
to world position y = -5
many thanks!
getting a bit closer
public GameObject trackPrefab;
public GameObject[ ] tracks = GameObject.FindGameObjectsWithTag(“track”);
private void trackSnap()
{
foreach (GameObject track in tracks) {
//move all objects found to y = -5
Debug.Log(track);
}
}
all tracks have been tagged
Code is not tested, but you should get the idea. This is supposed to be in the foreach block.
Vector3 position = track.transform.position;
position.y = -5.0f;
track.transform.position = position;