Separate 3 Spawned objects in 3 different positions instead of one position.

I want to Spawn Some Herbs in my game in 3 separate positions left, right, and center but they spawn in one position on top of each other.

These are the scripts for the spawning:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Spawner : MonoBehaviour
{

    public Transform[] spawnLocations;
    public GameObject[] whatToSpawnPrefab;
    public GameObject[] whatToSpawnClone;
    

    void spawnSomethingAwesomePlease()
    {
        whatToSpawnClone[0] = Instantiate(whatToSpawnPrefab[0], spawnLocations[0].transform.position, Quaternion.Euler(0,0,0)) as GameObject;



    }
}

This is the HerbSpawner:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

    public class HerbSpawner : MonoBehaviour
    {
        //Here, we declare variables.
        public Transform groupTransform;
        public GameObject[] allObjsToSpawnFrom;
    
        Vector2 spawnPos;
    
        void Start()
        {
            spawnPos = Camera.main.ViewportToWorldPoint(new Vector2(0.5f, 0.5f));
        }
    
        void Update()
        {
            // let's also spawn on button press:
            if (Input.GetMouseButtonDown(0))
            {
                RaycastHit2D hit = Physics2D.GetRayIntersection(
                    Camera.main.ScreenPointToRay(Input.mousePosition));
    
                if (hit.collider && hit.collider.CompareTag("Bush"))
                {
                    for (int i = 0; i < 3; i++) SpawnRandomly();
                }
            }
        }
    
        void SpawnRandomly()
        {
            int find = Random.Range(0, allObjsToSpawnFrom.Length);
            SpawnIt(allObjsToSpawnFrom[find]);
        }
    
        void SpawnIt(GameObject objToSpawn)
        {
            Vector2 spawnPos =
                Camera.main.ViewportToWorldPoint(new Vector2(0.5f, 0.7f));
            Instantiate(objToSpawn, spawnPos, Quaternion.identity, groupTransform);
        }
    }

I will try my best to answer this correctly, if I gather right. Your first problem, I think?

public Transform[] spawnLocations;

is supposed to be an array of Vector2’s? As transforms are basically gameObjects(technically). Second is you have this kinda setup to do a for loop:

void spawnSomethingAwesomePlease()
{
    whatToSpawnClone[0] = Instantiate(whatToSpawnPrefab[0], spawnLocations[0].transform.position, Quaternion.Euler(0,0,0)) as GameObject;
}

Which doesn’t “for” loop. It constantly would keep a value(index) of “0” being that of the one in the first slot of the array. And I am not sure why you have this, since you already have:

void SpawnIt(GameObject objToSpawn)
{
    Vector2 spawnPos =  Camera.main.ViewportToWorldPoint(new Vector2(0.5f, 0.7f));
    Instantiate(objToSpawn, spawnPos, Quaternion.identity, groupTransform);
}

^ this function that is already spawning. Which in this Instantiation setup you are constantly declaring to spawn at the same position of Vector2(0.5f, 0.7f)ScreenToWorld which appears to be spawnPos, which you actually declare twice.

But I see no positions, or random positions made for them to spawn left, right, or center? So you might just wanna set it up this way, then play around with it:

public class HerbSpawner : MonoBehaviour
{
    public Transform groupTransform;
	public GameObject[] allObjsToSpawnFrom;

	Vector2 spawnPos;

	void Start()
	{
		spawnPos = Camera.main.ViewportToWorldPoint(new Vector2(0.5f, 0.5f));
	}

	void Update()
	{
		if (Input.GetMouseButtonDown(0))
		{
			RaycastHit2D hit = Physics2D.GetRayIntersection(
			 Camera.main.ScreenPointToRay(Input.mousePosition));

			if (hit.collider && hit.collider.CompareTag("Bush"))
			{
				SpawnStuffRandomly();
			}
		}
	}
	void SpawnStuffRandomly()
	{
		int random = Random.Range(0,3); // max number doesn't work, so [0,1,2] if 3 in array?
		
		Instantiate(allObjsToSpawnFrom[random], spawnPos, Quaternion.identity, groupTransform);
	}
}

Obviously setup your own Vector2’s, or use Random.Range again, and modify your own Vector2’s within where you want to spawn them at.