I am stuck on a problem that might be quite simple yet it's getting on my nerves. I want to spawn crops on different plane shapes like in the attached screenshot.
So far my progress is that I am able to spawn crops with random distance with a certain number of rows and columns.
[ContextMenu("Generate Field")]
public void GenerateField()
{
GameObject wheatField = new GameObject();
wheatField.transform.position = transform.position;
int counter = 0;
for(int i = 0; i < rows; i++)
{
for (int j = 0; j < column; j++)
{
xDelta = Random.Range(0.4f, 0.5f);
yDelta = Random.Range(0.4f, 0.6f);
float yPos = Random.Range(-0.25f, 0.25f);
GameObject tempWheat = Instantiate(wheatPrefab, new Vector3(xDelta * i, 0, yDelta * j), Quaternion.identity
,wheatField.transform);
counter++;
}
}
Debug.Log("TOTAL CROPS PLACED = " + counter);
}
I want to do this in editor time, not runtime.
Below is the sample mesh I have where Orange, White, and Green are separate meshes.