- Home /
Question by
jacksterooney · Dec 11, 2012 at 02:08 PM ·
instantiate
My Instantiate script isn't working. Why?
Here's the script:
#pragma strict
var roomStraight = Transform;
var roomLeft = Transform;
var roomRight = Transform;
function Start () {
var roomSelector = Random.Range(1,4);
if(roomSelector == 1){
Instantiate(roomStraight, Vector3(transform.position.x-20, transform.position.y, 0), transform.rotation);
}
else if(roomSelector == 2){
Instantiate(roomLeft, Vector3(transform.position.x-20, transform.position.y, 0), transform.rotation);
}
else{
Instantiate(roomRight, Vector3(transform.position.x-20, transform.position.y, 0), transform.rotation);
}
}
I don't know what went wrong, and the message it is giving me is "No appropriate version of 'UnityEngine.Object.Instantiate' for the argument list '(System.Type, UnityEngine.Vector3, UnityEngine.Quaternion)' was found." Does anyone have any ideas?
Comment
Best Answer
Answer by BiG · Dec 11, 2012 at 02:14 PM
Change
var roomStraight = Transform;
var roomLeft = Transform;
var roomRight = Transform;
with
var roomStraight : Transform;
var roomLeft : Transform;
var roomRight : Transform;
Glad to know that, can you please accept the answer by clicking on the green tick symbol? Thanks!
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
GUI cale and position according to the actual screen resolution. 1 Answer
Raycast Destroys player. 1 Answer
OnTriggerEnter2D Rapid Fire 0 Answers
C# Reload Script 1 Answer