I have this script that spawns objects from the center of the game object, I want the script to spawn the objects randomly from the object, rather than only from the center how can i do this?
[SerializeField] float secondsBetweenSpawns = 2f;
[SerializeField] GameObject enemyPrefab;
void Start()
{
StartCoroutine(SpawnBlocks());
}
IEnumerator SpawnBlocks()
{
while (true)
{
Instantiate(enemyPrefab, transform.position, Quaternion.identity);
yield return new WaitForSeconds(secondsBetweenSpawns);
}
}
}
↧