In my player collision script I created public variable to represented the prefab of the matches.
var matchGUI : GameObject;
I then went to the unity and drag the prefab to the variable…
When the collision execute… all line executed except
matchGUIobj.name = matchGUI;
and the error below show up in the unity …
MissingFieldException: Field ‘UnityEngine.GameObject.name’ not found.
if (collisionInfo.gameObject.tag == "matchbox")
{
Destroy(collisionInfo.gameObject);
haveMatches = true;
audio.PlayOneShot (batteryCollect);
var matchGUIobj = Instantiate(matchGUI, Vector3(0.15,0.1,0),
transform.rotation);
matchGUIobj.name = matchGUI;
}
What am I missing ?
