| 123456789101112131415161718192021 |
- using UnityEngine;
- using System;
- using NUnit.Framework;
- using System.Collections.Generic;
- public class ForestManager : MonoBehaviour
- {
- public float treeSpawnRate = .1f;
- public float minHeight = .2f;
- public GameObject[] trees;
- public void SpawnTree(Vector3 pos, float meshHeightMultiplier)
- {
- System.Random rnd = new System.Random();
- if (rnd.NextDouble() < treeSpawnRate && (pos.y / meshHeightMultiplier) >= minHeight)
- {
- GameObject tree;
- tree = Instantiate(trees[0], pos, Quaternion.identity);
- }
- }
- }
|