- Home /
Question by
mdagreda · Dec 20, 2012 at 09:21 PM ·
gameobjectdestroy
How do I destory an object?
I thought this was simple I got this line from the unity API
Destroy (gameObject, 5);
and I declared the varable at the top like this.
var gameObject:GameObject;
but I am getting this error.
Assets/Destory.js(20,10): BCE0004: Ambiguous reference 'gameObject': Destory.gameObject, UnityEngine.Component.gameObject.
What am I doing wrong?
Comment
I put the destroy cammand in the update function. I also tried in the start function.
Best Answer
Answer by greatestprez · Dec 20, 2012 at 09:25 PM
Dont call your variable gameObject as that is the name of the GameObject on your current object. Simply use another name
Answer by JaydenM1997111 · Dec 21, 2012 at 12:53 AM
var object : GameObject;
Destroy(object);
Try that?