im trying to make a flappy bird type game and i used this script in order to instantiate the pipes infinitely :
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class pipespawner : MonoBehaviour
{
public float maxtime = 1;
private float timer = 0;
public GameObject pipe;
public float height;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if (timer > maxtime)
{
GameObject newpipe = Instantiate(pipe);
//newpipe.transform.position = transform.position + new Vector3(0, Random.Range(-height, height), 0);
Destroy(newpipe, 15);
}
timer += Time.deltaTime;
}
}
the pipes kinda stack on top of each other and look like this:
need help trying to understand this whole instantiate thing
