So I have a game and pipes need to spawn in random places, and it works fine at the start, but then the pipes start to multiply how many spawn each frame for some reason, and I could not find an article about it. I have tried coroutines but to the same result. I believe it has something to do with the random genrator. I have an input system to spawn. Here are the methods:(changed)`
public Vector3 spawn1;
public Vector3 spawn2;
public Vector3 spawn3;
public Vector3 spawn4;
public Vector3 spawnPos;
private int spawnPosNumber;
public GameObject pipe;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
public void Spawn()
{
Instantiate(pipe, new Vector3(0, Random.Range(5,-5)), transform.rotation);
}`