I’m having a bloody hell of a time figuring this one out. I’m close, very close. But I can’t connect it with prefabs.
A lot of what I have been looking at is in the following document:
http://unity3d.com/support/documentation/Manual/Instantiating%20Prefabs.html
However, I can’t connect the dots with the prefabs.
In my project I have a sphere prefab that can be picked up when you walk over it. I want to be able to instantiate it at runtime as I am going to be spawning the item in random spots over the map.
var cube : Transform;
function Start () {
for (var y = 0; y < 5; y++) {
for (var x = 0; x < 5; x++) {
var cube = Instantiate(cube, Vector3 (x, y, 0), Quaternion.identity);
}
}
}
From what I understand, I should be able to modify this code to work with my custom prefab that I’ve named spherePick (this is in the visual interface of Unity).
What am I missing here?