Need to know more about instantiates

Hi,

I was having trouble using Instantiates. I’ve read the script reference and another website about it.

From the reference page, it says:

var prefab : GameObject;

function Start()
{
 Instantiate(prefab, Vector3(0,0,0), Vector3(0,0,0));
}

Everytime I do that, I get this error = 'No appropriate version of ‘UnityEngine.Object.Instantiate’. So I got a bit confused since another website actually wrote the same way. Fortunately, after messing about, I can only instantiate an object when I write it as:

//inside function Start()
Instantiate(prefab);

How do I(if I wanted to):
Position the prefab anywhere I wanted or scale the prefab?

Thanks very much.

-Hakimo

The problem is for the 3rd argument you have a Vector3, when it should be a Quaternion (for a rotation).

Not sure which reference page you’re talking about, but this is the Unity Scripting Reference page for Instantiate, and I don’t see that example there.

To scale the object you could do something like this…

var newObject = Instantiate(prefab, transform.position, transform.rotation);
newObject.transform.localScale = Vector3(2.0,2.0,2.0);

This doubles the scale of the object.

EDIT: Whoops put the code in quotes.[/code]