10using System.Collections;
16 public Vector3
BallSize =
new Vector3(0.1f, 0.1f, 0.1f);
18 private IEnumerator _spawnCoroutine;
21 _spawnCoroutine = AddBallWithDelay(
BallPrefab);
25 StartCoroutine(_spawnCoroutine);
32 private IEnumerator AddBallWithDelay (GameObject prefab) {
39 private void addBall (GameObject prefab) {
41 GameObject go = GameObject.Instantiate(prefab);
42 go.transform.parent = transform;
43 go.transform.localPosition =
Vector3.zero;
45 Rigidbody rb = go.GetComponent<Rigidbody>();
46 rb.AddForce(
Random.value * 3, -
Random.value * 13,
Random.value * 3, ForceMode.Impulse);
49 private void removeBalls (
int count) {
50 if (count > transform.childCount) count = transform.childCount;
51 for (
int b = 0; b < count; b++) {
52 Destroy(transform.GetChild(b).gameObject);