public void SpawnSwarmBehavior() { framesTillNextBacteria_--; if (framesTillNextBacteria_ <= 0) { float max_height = Futile.screen.halfHeight; float min_height = max_height / 4.0f; float height = UnityEngine.Random.value * (max_height - min_height) + min_height; Vector2 initial_velocity = new Vector2(0, 0); initial_velocity.y = Mathf.Sqrt(2.0f * BacteriaBubble.accel * height); float air_time = (2.0f * initial_velocity.y) / BacteriaBubble.accel; initial_velocity.x = (player_.x - enemy_.x) / air_time; CreateBacteria(enemy_.GetPosition(), initial_velocity); framesTillNextBacteria_ = maxFramesTillNextBacteria_; enemy_.spawn_count++; } if (enemy_.spawn_count >= enemy_.NUM_SPAWNED_SWARM) { enemy_.curr_behavior_ = EnemyCharacter.BehaviorType.IDLE; enemy_.spawn_count = 0; } }