clonning again and again after sometime

void Update () {

		curspwntime -= 1 * Time.deltaTime;

		if (curspwntime <= 0) {
		
			instantiatedobj=Instantiate(geek1, new Vector3(-35.86f,6.3f,1.43f), Quaternion.Euler(0,90,0));		
			curspwntime = spawntime;
		
		}

the problem is after first tme it makes clone of clone .but i only want one clone after every 5 seconds and destroy OnCollisionEnter also doesnot work for clonned objects i had also used corroutines. thanks in advance.

Try doing that:

  • Create a method like (void SpawnObject())
  • And in the Start() add this InvokeRepeat(“SpawnObject”, TimeToStartSpawning, RepeatRate)
  • In your case RepeatRate would be 5