public class pipespwner : MonoBehaviour
{
    public GameObject pipe;
    public float spwanrate= 3;
    private  float  timer = 0;
    public float heightOffset = 10;
    // Start is called before the first frame update
    void Start()
    {

        spwanpipe();
    }

    // Update is called once per frame
    void Update()
    {
        if (timer < spwanrate)
        {
            timer = timer + Time.deltaTime;
        

        }
        else
        {
            spwanpipe();

            timer = 0;
        }

        
    }
    void spwanpipe()
    {
        float lowestPoint = transform.position.y - heightOffset;
        float highestPoint = transform.position.y + heightOffset;

        Instantiate(pipe, new Vector3(transform.position.x, Random.Range(lowestPoint, highestPoint), 0), transform.position);
    }
}