Question by
unkopath · Dec 09, 2018 at 02:08 PM ·
gameobjectsbehaviour
Weird gameobjects creating from nothing?
Hi, problem is when I call my script for instantiate enemies it creates my enemys, for example 4 enemies, then it creates 4 empty gameobjects aswell, can anyone tellme why this is happening? Here is the script
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AddRooms : MonoBehaviour {
public GameObject[] enemySpawners;
public GameObject[] enemies;
private int enemiesInRoom;
public int index;
void Start () {
foreach (var spawner in enemySpawners) {
GameObject enemy = Instantiate(enemies[Random.Range (0,enemies.Length)],spawner.transform.position,transform.rotation);
enemy.GetComponent<EnemyController> ().fromRoomIndex = index;
enemiesInRoom = enemiesInRoom + 1;
}
}
}
Comment