jongallant / WorldGeneratorFinal

Procedural world map generator

Home Page:http://www.jgallant.com/procedurally-generating-wrapping-world-maps-in-unity-csharp-part-4/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Convert to Unity terrain?

Zyles opened this issue · comments

commented

Hey really nice tutorial and project.

I am pretty new to Unity so I wonder what steps would you need to take to convert this into Unity terrain?

Thanks.

Also interested in this!

You can do this by using the Terrain.terrainData.SetHeights(0,0,Data); method. You can simply pass it the HeightMap.Data array to get started. You will want to normalize the data before you pass it to this function.

You could do this by adding the following in MapData -- then calling it of course, to normalize it.

public void Normalize() { for (int x = 0; x < Data.GetLength(0); x++) { for (int y = 0; y < Data.GetLength(0); y++) { Data[x,y] = Data[x, y] = (Data[x, y] - Min) / (Max - Min); } } }

This should give you a start on how to accomplish this.
I do not plan on tackling this feature in this project at this point in time, but it can be done with the above method.