public Composite SpawnCube( Vector2 pos, float angle, float relativeForce, float burstDuration, float burstDelay, Color color) { Composite comp = CompositePool.Instance.ForceCreateComposite(); if (comp != null) { CubeScript spawned = null; float rand = Random.value; if (rand < cubeProb) { spawned = SpawnCube(relativeForce, burstDuration, burstDelay, color); } else if (rand < cubeProb + 0.0f) { //TODO: add probability based spawning } //center random position spawned.transform.position = transform.TransformPoint(new Vector3(pos.x, pos.y, 0.0f)) + 0.5f * Vector3.one; spawned.transform.rotation *= Quaternion.AngleAxis(angle, Vector3.up); spawned.transform.parent = comp.transform; comp.Color = spawned.Color; comp.HP = 1; comp.AbsorbRigidbody(spawned.GetComponent <Rigidbody>()); Destroy(spawned.GetComponent <Rigidbody>()); comp.CreateTarget(); } return(comp); }