Instantiating A Grass Prefab Multiple Times

So I want to instantiate a grass prefab I have multiple times. The goal is to instantiate what will, to the player, look like a field of grass, and then make it cuttable with something like Piecemaker. However, as a person new to coding (although I have a VERY basic knowledge of C++) I’m having trouble getting this done. I’ve looked into Object.Instantiate, and it might do what I want, but again I’m a noob coder and have very little idea how to use it appropriately. Also, I realize the large amount of system resources that this would probably take up, so if anyone has a different method of creating cuttable fields of grass, please let me know.

Using game objects for every individual patch of grass probably means having lots and lots of game objects, resulting in slow down. I don’t know if Unity Terrain engine is an option for you, if so you could make grass detail objects and dynamically update the amount of grass detail in the terrain.

void UpdateGrass(float x, float y, int ) {
	int offsetX = (x * myTerrain.terrainData.detailResolution / TERRAIN_WIDTH);
	int offsetY = (y * myTerrain.terrainData.detailResolution / TERRAIN_HEIGHT);
	int[,] newDetail = new int[,] { {0} };
	myTerrain.terrainData.SetDetailLayer(offsetX, offsetY, GRASS_LAYER, newDetailAmount);
}

If terrain engine isn’t an option, consider combing the instances of the gameobjects, there should be some examples around on the Unity wiki. If you can’t find anything just drop me a note. Of course, combining them makes it a bit harder to remove an individual patch.

If you just want to work with dynamically instantiate the grass and not worry about performance, look in the scripting reference for `Object.Instantiate’. Should give a fairly decent description of how it works.