Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class TreeGen : MonoBehaviour
- {
- public int numberOfTreesPerChunck;//How many trees you want per chunk
- public GameObject treePrefab; //Prefab of the tree so we can spawn it
- public void GenTreeForChunk() //Once the points are all added we need to call this to spawn the trees
- {
- Vector3[] points = meshData.ReturnVertices();//This returns all of the vertexs
- for (int i = 0; i < numberOfTreesPerChunck; i++) // This will loop for the amount you want to spawn on that chunk
- {
- GameObject lastTree = Instantiate(treePrefab); //Spawns the prefab
- lastTree.transform.position = points[Random.Range(0, points.Length)]; //Sets the position of it
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement