using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEditor; public class LeafSpawner : MonoBehaviour { public float Radius = 3; public float Rate = 5; public LeafPhysics Leaf; // Use this for initialization void Start () { } private List<LeafPhysics> leaves = new List<LeafPhysics>(); private float time = 0; // Update is called once per frame void Update () { float interval = 1 / Rate; time += Time.deltaTime; while (time > interval) { time -= interval; Vector2 offset = Random.insideUnitCircle; Vector3 point = transform.position + new Vector3(offset.x * Radius, 0, offset.y * Radius); LeafPhysics leaf = GameObject.Instantiate<LeafPhysics>(Leaf); leaves.Add(leaf); leaf.transform.position = point; } } }