- Home /
Question by
twotostudio · Nov 11, 2021 at 12:03 PM ·
spawn
When I have spawned a certain number of soldiers at a point, how can I spread them out in a circular fashion?
I'm trying to copy some kind of stickman army. When soldiers come to a door, they spawn a certain number of soldiers. How can I spread these spawning soldiers in order? Now they all appear in the same place and are intertwined. I want to have them disperse in a circular fashion.
public class MultiplyGates : MonoBehaviour
{
public GameObject GameObjectToSpawn;
private GameObject Clone;
private int spawnSayisi;
private bool multiplyDegdi = false;
public Transform spawnnokta;
private void Start()
{
multiplyDegdi = false;
}
void Update()
{
if (multiplyDegdi == true)
{
for(int i=0; i<20; i++)
{
Clone = Instantiate(GameObjectToSpawn, spawnnokta.transform.position, Quaternion.identity);
Clone.transform.parent = this.transform.parent.transform;
if (i == 19)
{
multiplyDegdi = false;
}
}
}
}
private void OnTriggerEnter(Collider other)
{
if (other.gameObject.CompareTag("Multiply"))
{
multiplyDegdi = true;
}
}
}
Comment
Your answer