title: Object spawn on procedural terrain spawns on unspecified area
body: <p>I've managed to put together a procedural terrain with defined regions and I am looking to procedurally place objects within the world within these regions. The regions are defined by their height and I am trying to utilise this to correctly place certain objects in certain regions however my result seems to come out slightly odd where objects are able to spawn outside the defined region height. I am using an <code>AnimationCurve</code> as a mesh height curve to prevent water areas from becoming terrain like. I am unsure if this is causing the issue behind in the correct placement. Would appreciate any insight into where I might be going wrong</p>
  <p><strong>Defined regions:</strong>
  <a href="https://i.stack.imgur.com/7s3GQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7s3GQ.png" alt="enter image description here" /></a></p>
  <p>The <code>Rock</code> region is defined with a height of <code>0.7</code> and I try to spawn trees on the map only at a <code>Rock</code> location</p>
  <p><strong>Spawning object (Spawn 10) at rock location</strong></p>
  <pre><code>    int amount = 0;
      for (int y = 0; y &lt; mapHeight; y++)
      {
          if(amount &lt; 10)
          {
              for (int x = 0; x &lt; mapWidth; x++)
              {
                  float currentHeight = noiseMap[x, y];
  
                  if(currentHeight.ToString(&quot;f1&quot;) == (0.7f).ToString())
                  {
                      Debug.Log(currentHeight.ToString(&quot;f1&quot;));
  
                      Vector3 spawnPosition = new Vector3(Random.Range((x), (mapWidth / 2)), currentHeight, Random.Range(y, (mapHeight / 2)));
                      var block = Instantiate(AssetsToSpawn[0].AssetPrefab, spawnPosition, Quaternion.identity);
                      block.transform.SetParent(this.transform);
                      amount++;
                      break;
                  }
  
              }
          } else
          {
              return;
          }
  </code></pre>
  <p><strong>Result</strong></p>
  <p>Some seem to spawn in the right location albeit looking slightly weird but the one on the far left is finding itself on flat land, with water and sand; an area not defined as <code>0.7</code> or <code>Rock</code> type.
  <a href="https://i.stack.imgur.com/JPU1P.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JPU1P.jpg" alt="enter image description here" /></a></p>