I have a few kind of enemy in my folder prefab. Also, i have 8 kind of position
i want to spawn random enemy with random position. But i cant understand, how initialize some kind of enemy from my folder “prefab”
Vector2 botVector = new Vector2(0f, -13.8f);
Vector2 botLeftVector = new Vector2(-14.8f, -8f);
Vector2 leftVector = new Vector2(-16.3f, 0f);
Vector2 topLeftVector = new Vector2(-11.2f, 6f);
Vector2 topVector = new Vector2(0f, 8.6f);
Vector2 topRightVector = new Vector2(12.2f, 5.2f);
Vector2 rightVector = new Vector2(15.8f, 0f);
Vector2 botRightVector = new Vector2(13.6f, -8.4f);
Vector2[] allVectors = new Vector2[8];
int randomPosition;
void setupVectors() {
allVectors [0] = botVector;
allVectors [1] = botLeftVector;
allVectors [2] = leftVector;
allVectors [3] = topLeftVector;
allVectors [4] = topVector;
allVectors [5] = topRightVector;
allVectors [6] = rightVector;
allVectors [7] = botRightVector;
}
// Use this for initialization
void Start () {
setupVectors();
}
// Update is called once per frame
void Update () {
randomPosition = Random.Range (0, allVectors.Length);
}