Procedural Map

Hello there, I am currently working on my survival game, I need a little bit of help with procedurally generating my island. Currently, I have a 500x500 terrain gameobject. I have managed to find some code (after 2 hours) that works when amended to my personal use. Here is the code;

using UnityEngine;
using UnityEditor;
using System.Collections;

public class ProceduralGeneration : MonoBehaviour
    {

        public Terrain terrain;

        void generateMap()
            {
                TerrainData TD = terrain.terrainData;
                float[,] HeightMap = new float[TD.heightmapWidth,TD.heightmapHeight];
                for(int x=0;x<TD.heightmapWidth;x++)
                    {
                        for(int y=0;y<TD.heightmapHeight;y++)
                            {   
                                HeightMap [x, y] = Random.Range (10, 15);
                            }
                    }

                TD.SetHeights(0,0,HeightMap);

            }

        void Start()
            {
                generateMap();
            }


    }

However, this code, despite working, works incorrectly.

As seen in the picture posted above, you can probably gather that I don’t want that. Here is an example (Not exact) of what I want http://www.aolcdn.com/photogalleryassets/mydailyuk/911871/guana-island-1300.jpg

Help with the foliage, and textures is appreciated but not mandatory. Thanks.

Hey CraftCreeperDev,

I apologize that I am unable to help your coding problem, but I saw that you didn’t have a response yet so I thought I would let you know that I had seen a Unity tutorial series on this that I watched for procedurally generating land mass.

It’s on this page in the Unity tutorial section, and this one was about cave generation: Procedural Cave Generation - Unity Learn

However on his YouTube channel, he had made another one about land mass and terrain generation: http://www.youtube.com/playlist?list=PLFt_AvWsXl0eBW2EiBtl_sxmDtSgZBxB3

They’re 2 and a half hours long, and I know you’d probably have to re-do some stuff but thought maybe it could help you. Have a great and productive day :).

That is a lot of videos… I appreciate your kindness and will begin watching them. Thanks (:

No problem, best of luck and maybe someone can stop by soon to help your script problem more thoroughly.

I have an issue, I cannot apply the noise map (softened heightmap).

The noise map is 100% working as it’s visible on my plane.

https://gyazo.com/09373820f2634ec8fdc1bb92fc6f7373

However, doesn’t want to apply the my terrain.

The code is as follows;

            terrain.terrainData.SetHeights(0, 0, noiseMap);
            terrain.Flush ();

I have tried it with and without flush.

After debugging noiseMap, it apparently returns an empty array, but when used in my other method, returns perfectly fine. Then again, printing the length returns an array with 1000+ values.

Anyone got any idea?