- Home /
No appropriate version of 'UnityEngine.Object.Destroy' for the argument list '(System.Type)' was found
I am using the free version of unity for the mac, and I'm currently using the FPS tutorial. My problem is that when I try to use this script:
var explosion : GameObject;
function OnCollisionEnter (collision : Collision) {
var contact : ContactPoint = collision.contacts[0];
var rotation = Quaternion.FromToRotation(Vector3.up, contact.normal);
var instantiatedexplosion : GameObject = Instantiate(explosion, contact.point, rotation);
Destroy(GameObject); }
I get the console message that I used for the title of the question:
No appropriate version of 'UnityEngine.Object.Destroy' for the argument list '(System.Type)' was found
I am still very green in regards to game design (I'm just now learning anything about scripting) so any advice is welcome.
Answer by duck · Apr 20, 2010 at 07:21 AM
You need a lower-case 'g':
Destroy(gameObject);
With a capital G, the word "GameObject" refers to the type - or the "class" - of objects called GameObject.
With a lowercase g, "gameObject" refers to the gameObject variable which contains a reference to the particular GameObject on which this script is placed.
You can destroy instances of GameObject, but you can't destroy the GameObject class itself!
Good explanation of the distinction between classes and instances +1.
Thanks, explained fully perfect for someone just starting to understand it!
Thanks a lot man. That helped something I was fixing from few hours :D
Your answer
Follow this Question
Related Questions
error when played in unity engine 1 Answer
using Contains(gameObject) to find and destroy a gameObject from a list 2 Answers
How "include" the Raycast?! 1 Answer
AudioClip won't play?? 0 Answers
Instantiate Problem 1 Answer