using System.Collections; using System.Collections.Generic; using UnityEngine; public class GeneratorWithDelay : MonoBehaviour { public GameObject obj; public float randX = 20f; public float randZ = 20f; public float startDelay = 0f; public float delay = 1f; public float lifeTime = 10f; Vector3 tmp; void Start() { InvokeRepeating("F1", startDelay, delay); } void F1() { tmp = new Vector3(Random.Range(-randX, randX), transform.position.y, Random.Range(-randZ, randZ)); GameObject my = Instantiate(obj, tmp, Quaternion.identity); my.GetComponent().AddTorque(100, 100f, 100f); Destroy(my, lifeTime); } }