Hello, I’m trying to get a script component from an instantiated object, but when I try to access any members from the script it gives me Null Reference Exception. The BlockBehaviour script is attached to the game object.
public GameObject block;
public GameObject gBlock;
gBlock = (GameObject)Instantiate(block, this.transform.position, Quaternion.identity);
if (gBlock){
//Tell the DragCamera script that we are holding a block
DragCamera.onBlock = true;
//Get the block script
//bb = (BlockBehaviour)gBlock.GetComponent<BlockBehaviour>();
//Set alpha level to 0.6
gBlock.GetComponent<BlockBehaviour>().setTransparent(0.6f);
}