When i’m instantiating some clouds to my game, the clones dont get the game object, being “none” it appears a lot of errors in my console but the game doesnt stop.
look the picture
I should do something in my scripts to those clones get the game Object, called “Nuvem”, like in the Hierarchy you can see.
i’ll post my scripts here.
First the cloud script
public class nuvemController : MonoBehaviour {
public float velocidade;
public Transform transformNuvem;
public GameObject objectNuvem;
void Start () {
}
// Update is called once per frame
void Update () {
transformNuvem.Translate(velocidade * Time.deltaTime* -1, 0, 0);
if (objectNuvem.transform.localPosition.x < -13){
Destroy(objectNuvem);
}
}
}
now the instantiator script
public class Instanciador : MonoBehaviour {
public GameObject prefab;
public float rateSpawn;
public float currentTime;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
InstanciarNuvem();
}
void InstanciarNuvem()
{
currentTime += Time.deltaTime;
if (currentTime >= rateSpawn)
{
currentTime = 0;
Instantiate(prefab, transform.position, transform.rotation);
}
}
}
I think that i should put something in the Start() to initializate those clones with the cloud object. how should i correct this error?