Mass place prefabs

I made a prefab of a cactus which contains a collider, rigidbody, and a script.
I want this prefab to be mass placed all over the map (about 2000) But when i cant use it as a tree in the terrain editor. When i paint them over my map they are very tiny, and does not have the attached components that i gave them. And i cant adjust the size.

A sort of solution I think would be possible would be to use a ray attached to an empty game object.

Do a for loop where it moves the empty game object to a random value that is limited to the size of your map. Keep it above your terrain and then use the hit.point’s location to place the cactus prefab.

Basically something like this:

//Create a ray here using physics.raycast. Have it
//above the ground and pointed toward the ground. 
    
    for(int i = 0; i < 2001; i++)
    {
       rayObject.transform.position = new Vector3(Random.Range(0, 2000), 500, Random.Range(0, 2000));
       Instantiate(Cactus, hit.point, Quaternion.identity);
    }

In theory, something like that should work. What you can then do is, play the game, it’ll spawn all the cactus. Select all the cactus that are spawned and copy them. Now stop the game, it’ll delete all the cactus, now paste the cactus. They will be pasted exactly where the script ran.

Now delete the script and you should have a bunch of randomly placed cactus. ^^

Unless you want to spend weeks working on a editor extension to do this I recommend buying one from the Unity asset store. There are some free ones but I recommend getting the paid ones if you want good results fast.

Free: Unity Asset Store - The Best Assets for Game Making
Paid: Unity Asset Store - The Best Assets for Game Making