public void ReturnAsteroid(VoroAsteroid asteroid) { // Make sure that the object is disabled asteroid.gameObject.SetActive(false); asteroidPool.Enqueue(asteroid); }
public void SpawnAsteroid() { if (asteroidPool.Count == 0) { return; } // Get the spawn point Vector3 newPos = SpawnPoint(); // Get an object from the object pool. Set the position VoroAsteroid va = asteroidPool.Dequeue(); // Activate the object Vector3 velocity = new Vector3(); velocity.x = this.wind.x; velocity.y = this.wind.y; velocity.z = 0.0f; Vector3 angvel = new Vector3(); angvel.x = Random.Range(-0.5f, 0.5f); angvel.y = Random.Range(-0.5f, 0.5f); angvel.z = Random.Range(-0.5f, 0.5f); va.Enable(newPos, velocity, angvel); }