Hello, I’m new to using javascript and I am having some trouble.
In my assets folder, I have a prefab named “enemyprefab”, and I am trying to make a script so a copy of the prefab will spawn at the location of the object I have attatched the script to. Looking at the Unity manuals on the instantiate command and its discussion of instantiating prefabs, led me to believe that this code:
#pragma strict
var enemyprefab : Transform;
function Start () {
Instantiate(enemyprefab, Vector3 (x, y, 0), Quaternion.identity);
}
function Update () {
}
would give me the result I need, but unfortunately it doesn’t work at all. I’ve looked at other questions on this website about this topic, but I just can’t figure out what to do.
Any help is appreciated.