i have tried over an over to post this question on the answers.unity3d website but i could post it for some reason tried many time .
please help
using UnityEngine;
using System.Collections;
public class Generate : MonoBehaviour {
public GameObject lightnest;
public float initialDelay;
public float finalDelay;
public float rampDuration;
protected float _delay;
protected float _runTime;
protected float _timeSinceSpawn;
// Use this for initialization
void Start () {
_delay = initialDelay;
_runTime = _timeSinceSpawn = 0.0f;
}
// Update is called once per frame
void Update() {
_runTime += Time.deltaTime;
_timeSinceSpawn += Time.deltaTime;
_delay = Mathf.Lerp(initialDelay, finalDelay, _timeSinceSpawn / rampDuration);
if (_timeSinceSpawn > _delay) Spawn();
}
protected void Spawn()
{
_timeSinceSpawn = 0.0f;
Instantiate(lightnest);
}
}
So this is the code which i use to generate the pipe thingys ,but after it genrates it i want to destroy it after its out of screen or any other possible way ,maybe after 3sec or any way possible and i want this pipe thingys to generate randomely in different sizes you get me ryt just like flappy bird