Hello,
I’m trying to make an overlay and i want to instantiate the hearts in the “Overlay” GameObject.
I searched on Internet (i actually tried things found in the first two pages of google) but nothing works.
Here is my code :
using UnityEngine;
using System.Collections;
public class Overlay : MonoBehaviour {
public Transform CoeurPlein;
public Transform CoeurVide;
// Use this for initialization
void Start () {
GameObject TCoeurPlein = Instantiate (CoeurPlein, new Vector3 (0,0, 0), Quaternion.identity) as GameObject;
TCoeurPlein.transform.parent = GameObject.Find("Overlay").transform;
}
// Update is called once per frame
void Update () {
}
}
And the error message :
NullReferenceException: Object reference not set to an instance of an object
Overlay.Start () (at Assets/script/Overlay.cs:13)
Thanks