Get the transform.position of a gameobject in an array?

Hello!

I am trying to get the position of the last gameobject in an array. What i get is the starting position only, not the updated one that i need. Very strange since i check for the position in the update function:

using UnityEngine;
using System.Collections;

public class TileGeneration : MonoBehaviour {

	public GameObject plainTile;
	public float x;
	public float y;
	public GameObject[] startTiles;
	public Vector3 lastTilepos;

	void Start () {

		for (int i = 0; i < 6; i++)
			
		{	
			startTiles *= plainTile;* 

_ Instantiate (startTiles*,new Vector3(x,y,0),transform.rotation);_
_
x = x + 2.4f;_
_
}_
_
}*_

* void Update () {*

* lastTilepos = startTiles [startTiles.Length - 1].transform.position;*

* }*
}

Any ideas?
Thank you!

In 16 you’re assigning the prefab to the array. Then you instantiate it, BUT it’s just in the scene and not assigned anywhere (It’s a new instance). Instantiate plainTile and assign the returned gameobject to your array, then you’re referencing the new instance and not the prefab anymore.

Change:

startTiles*=plainTile;*

Instantiate(startTiles*,new Vector3(x,y,0),transform.Rotation);*
into:
startTiles*=Instantiate(painTile,new Vector3(x,y,0),transform.Rotation) as GameObject;*