I’m instantiating objects and trying to parent them if the conditions are met to an object in the array.
Confused, what am I missing.
public class SpawnBlock : MonoBehaviour
{
public GameObject[] BlockOne;
public GameObject[] Parent;
void OnMouseDown()
{
Parent = GameObject.FindGameObjectsWithTag ("TileNew");
BlockOne = GameObject.FindGameObjectsWithTag ("Blocks");
foreach (GameObject r in Parent)
{
if (r.GetComponent <NewTiles> ().NewTileSpawned == 0) {
//Parenting BlockOne to Parent that has NewTileSpawned == 0 in the array
BlockOne.transform.SetParent (Parent);
transform.localPosition = new Vector3 (0, 0, -1);
}
}
}
}
Line 17 BlockOne.transform.SetParent (Parent); gives me this :
Assets\CustomScripts\SpawnBlock.cs(25,14): error CS1061: ‘GameObject[ ]’ does not contain a definition for ‘transform’ and no accessible extension method ‘transform’ accepting a first argument of type ‘GameObject[ ]’ could be found (are you missing a using directive or an assembly reference?)
I tried to change GameObject to Transform in the Parent declaration but it gives even more errors.