- Home /
Question by
AMDAndrew · Oct 01, 2012 at 02:43 PM ·
gameobjectinstantiatequaternion
UnityEngine.Object.Instantiate
Hi,
I'm keep having this problem trough I have read about it :
No appropriate version of 'UnityEngine.Object.Instantiate' for the argument list '(System.Type, UnityEngine.Vector3, UnityEngine.Quaternion)' was found.
#pragma strict
var explosion = GameObject;
function OnCollisionEnter (collision : Collision) {
if (collision.gameObject.tag == "Player") {
var contact : ContactPoint = collision.contacts[0];
var rotation : Quaternion = Quaternion.FromToRotation(Vector3.up, contact.normal);
var instantiatedExplosion : GameObject = Instantiate (explosion, contact.point, rotation);
Destroy(gameObject);
}
}
function Start () {
}
function Update () {
}
Thaks for further help :)
Comment
Best Answer
Answer by aldonaletto · Oct 01, 2012 at 02:48 PM
This line is wrong:
var explosion = GameObject;
It creates a variable of type System.Type and assigns the type GameObject to it.
The correct line is:
var explosion: GameObject;
and you must drag the explosion prefab to this field in the Inspector, or a Null Reference error will occur.