Skip to main content

I tried every different way of instantiating a game object and the value of pos z would only be correct for the first one instantiated. The only thing that would work for me is Instantiating the Game Object and then setting the localPosition.

It would look something like this.

int tileIndex = Random.Range(0, TileSet.Count - 1);
Vector3 position = new Vector3(x, y, 0.0f);
GameObject newTile = Instantiate(TileSet[tileIndex], position, this.transform.rotation, this.transform); 
newTitlenewTile.transform.localPosition = position; // Don't set position, set localPosition

I tried every different way of instantiating a game object and the value of pos z would only be correct for the first one instantiated. The only thing that would work for me is Instantiating the Game Object and then setting the localPosition.

It would look something like this.

int tileIndex = Random.Range(0, TileSet.Count - 1);
Vector3 position = new Vector3(x, y, 0.0f);
GameObject newTile = Instantiate(TileSet[tileIndex], position, this.transform.rotation, this.transform); 
newTitle.localPosition = position; // Don't set position, set localPosition

I tried every different way of instantiating a game object and the value of pos z would only be correct for the first one instantiated. The only thing that would work for me is Instantiating the Game Object and then setting the localPosition.

It would look something like this.

int tileIndex = Random.Range(0, TileSet.Count - 1);
Vector3 position = new Vector3(x, y, 0.0f);
GameObject newTile = Instantiate(TileSet[tileIndex], position, this.transform.rotation, this.transform); 
newTile.transform.localPosition = position; // Don't set position, set localPosition
Source Link

I tried every different way of instantiating a game object and the value of pos z would only be correct for the first one instantiated. The only thing that would work for me is Instantiating the Game Object and then setting the localPosition.

It would look something like this.

int tileIndex = Random.Range(0, TileSet.Count - 1);
Vector3 position = new Vector3(x, y, 0.0f);
GameObject newTile = Instantiate(TileSet[tileIndex], position, this.transform.rotation, this.transform); 
newTitle.localPosition = position; // Don't set position, set localPosition