How to Instantiate(pool) one object after other rather than Random.range?

Can you guys help me with my problem. How do I instantiate (in this case pool) objects one after the other (i.e Object 0 and then Object 1…Object6) rather than generating Randomly(random.range)? and then start from 0 again. This script generates objects at random.

public ObjectPool[] objectPools;

private int randomBlockSelector;

void Update()
{
        if (transform.position.y < TriggerPoint.position.y)
        {
            randomBlockSelector = Random.Range(0, 7);

        transform.position = new Vector3(transform.position.x, transform.position.y, transform.position.z);

        GameObject newBlock = objectPools[randomBlockSelector].GetPooledObject();
        newBlock.transform.position = transform.position;
        newBlock.transform.rotation = transform.rotation;
        newBlock.SetActive(true);        
        }
}

Good day.

You can create a int variable as a counter and add this

void Start()
  {
  int counter = 0;
  }

....

GameObject newBlock = objectPools[counter].GetPooledObject();
counter++;
if(counter > lastindexnumber)
  {
  counter = 0;
  }

So, you will be instantiating 1 by 1.


If helped, accept the answer and close the question!
Bye!

Thank you very much. This worked.