instantiate prefab in project folder

What’s the proper script for instantiating a prefab from the project folder into the hierarchy during runtime.

In the project folder is Flames which is a prefab particle system.

I’ve tried a few things already which made sense to me but they didn’t work.

Like

myprefab=Instantiate(Flames);

But nothing is working.

Thanks,

Dan

This works

I put the prefab named “dog” in the Resources Folder…if you don’t have a Resources Folder make one.

mynewprefab = Instantiate(Resources.Load(“dog”));

Dan

Hi normally, you would write it like so;

In C#

GameObject go = (GameObject)Instantiate(GameObject.Find("Flames"), new Vector3(0.0f, 0.0f, 0.0f)); 
//For the new vector3, type the position where you want it to appear.

For more information;

I think what is missing here, and can be seen in the scripting manual on instantiate, is that you create a variable in the script that is exposed in the inspector. Choose the prefab in the inspector using the popup menu, and you are set. Right?

var prefab : Transform;

function Start() {
myPrefab=Instantiate(prefab,Vector3.zero,Quaternion.identity);
}

Here is how I do it.

var player : GameObject;

function CreatePlayer(){
Instantiate(player, Vector3(0,0,0),Quaternion.identity);
}