- Home /
No appropriate version of 'UnityEngine.Object.Instantiate. Please Help :(
Hi i am creating a basic game where you shoot basketballs into a box. I am seeming too have an error with one of my scripts that deals with destroying the basketball once it has gone in the box and re spawning it the error is:
Assets/ContactRespawn.js(7,43): BCE0023: No appropriate version of 'UnityEngine.Object.Instantiate' for the argument list '(System.Type, UnityEngine.Vector3, UnityEngine.Quaternion)' was found.
here is the code:
pragma strict
var thePrefab = GameObject;
function OnCollisionEnter(theCollision : Collision) {
if(theCollision.gameObject.name == "Plane") {
Destroy(gameObject.Find("Sphere"), 1);
var instance : GameObject = Instantiate(thePrefab, transform.position, transform.rotation);
} else if(theCollision.gameObject.name == "Hole") {
Destroy(gameObject.Find("Sphere"), 1);
var instance : GameObject = Instantiate(thePrefab, transform.position, transform.rotation);
}
}
Any help would be great thanks :) P.S. i am mildly experienced with coding
Hello
As said in your error message, you need a quaternion for the third argument not a rotation :)
Answer by gjf · Jul 21, 2014 at 11:19 AM
line 2:
var thePrefab = GameObject;
should be
var thePrefab : GameObject;
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
whats wrong with my code? 1 Answer
"Expecting ), found ';'" and "';' expected. Insert a semicolon at the end" 1 Answer
Animation spins wildly after completed 0 Answers
BCE0049 error with network script 0 Answers