Question by
luberisselud · Apr 08, 2021 at 02:22 PM ·
gameobjecttransformspawning problems
Battle stations for my RPG game
Hello! I have been trying to make so my ennemies appear properly on their battle stations once the battle starts. Let me explain:
My script makes up to 3 enemies appear during battles and I have a 3 battle stations to place those enemies. The code I have made is based on the turn-based battle tutorial from Brackeys:
//Add the enemies by selecting a random amount that pops up during battle
for (int i = 0; i < Random.Range(1,4); i++){
//Select randomly from the pool of ennemies
enemy = enemyPrefab[Random.Range(0,enemyPrefab.Length)];
//Store these enemies in a list we'll use later
allEnemies.Add(enemy);
Debug.Log(allEnemies.Count);
//Select from the pool of battle stations
Transform bs = enemyBS[Random.Range(0,enemyBS.Length)];
GameObject enemyGO = Instantiate(enemy, bs);
enemyUnit = enemyGO.GetComponent<Unit>();
}
My problem is that sometimes there are 2 ennemies on the same battle station and I don't want that. I don't know how to solve this problem, so if there's any solutions people could find for that, I would really appreciate it!
Comment