1
0

Forest Manager.cs 580 B

123456789101112131415161718192021
  1. using UnityEngine;
  2. using System;
  3. using NUnit.Framework;
  4. using System.Collections.Generic;
  5. public class ForestManager : MonoBehaviour
  6. {
  7. public float treeSpawnRate = .1f;
  8. public float minHeight = .2f;
  9. public GameObject[] trees;
  10. public void SpawnTree(Vector3 pos, float meshHeightMultiplier)
  11. {
  12. System.Random rnd = new System.Random();
  13. if (rnd.NextDouble() < treeSpawnRate && (pos.y / meshHeightMultiplier) >= minHeight)
  14. {
  15. GameObject tree;
  16. tree = Instantiate(trees[0], pos, Quaternion.identity);
  17. }
  18. }
  19. }