void createBoid(float rate) { int amount = Mathf.FloorToInt(rate); for (int i = 0; i < amount; i++) { //if (count > maxBoids - 1) return; float angle = Random.value * MathExt.TWO_PI; bool isRadiusRandom = Random.value < 0.2f; float radiusStart = isRadiusRandom ? 0 : 0.7f; float radiusAmount = isRadiusRandom ? 1 : 0.3f; float radius = (radiusStart + Random.value * radiusAmount) * birthArea.x; Vector3 pos = transform.position + new Vector3(Mathf.Cos(angle) * radius, Random.Range(-birthArea.y, birthArea.y), Mathf.Sin(angle) * radius); GameObject f = Instantiate(boidPrefab, pos, Quaternion.identity, transform) as GameObject; Particle p = f.GetComponent <Particle>(); p.init(this, currentShapeIndex, pallete.random(), metallic, smoothness); //particles[count] = p; count++; } }
public void swapPallete(int index) { if (index > palletes.Length - 1) { index = palletes.Length - 1; } currentPalleteIndex = index; pallete = palletes[index]; if (index == 0) { camera.backgroundColor = Color.white; } else { Color whiteOrBlack = Random.value < 0.3 ? Color.white : Color.black; camera.backgroundColor = Random.value < 0.5 ? pallete.random() : whiteOrBlack; } }