I was trying to make a Game about Collapse game thingy as a school Project but then it comes to an error
using UnityEngine;
using System.Collections;
public class Spawner : MonoBehaviour
{
public GameObject[] Block; // Takes all the tagged Colour Block
public GameObject[][] BlockCounter; // the Spawned GameObject are stored here
public Vector3[][] BlockPosition; // The Position of the Block in float
// Use this for initialization
void Start ()
{
Block = GameObject.FindGameObjectsWithTag("Block");
int number=0;
for (int x=0 ; x<10 ; x++)
{
number = Random.Range(0,3);
BlockCounter[0][x]=Block[number];
Instantiate (BlockCounter[0][x], new Vector3 (0,0,0) , transform.rotation);
}
}
// Update is called once per frame
void Update ()
{
}
}
i have 4 GameObject that is tagged “Block” and i wanna to copy it to the array multiple times with different position (so i can access another script in each of the duplicated block individually and be able to modify it) and randomly so the block would shuffle the colour but the error its showing is :
NullReferenceException: Object reference not set to an instance of an object
Spawner.Start () (at Assets/Script/Spawner.cs:19)
Please help…desperately new Unity Student is dying ! im really confused, forgive me if this is a basic wrong.