- Home /
How can I programmatically stretch a Terrain?
I'm attempting to achieve a low-resolution terrain by importing a small (32x32) heightmap into a TerrainData via the SetHeights() function and then somehow scaling the resulting terrain so that it covers more area (256x256) with the same number of vertices. I need to do this programmatically rather than in the editor because the landscape must be procedurally-generated at runtime.
I've attempted to do this by setting the TerrainData HeightmapResolution and size to 33 initially, then setting the size again after calling SetHeights(). This seems to cause the edges of adjacent terrain tiles to no longer line up, so I must be doing something wrong here.
Any advice on this would be greatly appreciated, even if it requires an entirely new approach.
Edit: Better description.
The difference between a 32x32 v 256x256 heightmap should be relatively small, so why not just start with a 256x256 and forgo the scaling issues
$$anonymous$$y problem is that all of the procedural generation I'm doing on these is having an impact on performance, and I honestly don't need terrain with such a high resolution. If I could just scale the Terrain objects in some way, it would solve all of my problems.
Answer by will.miller · Apr 10, 2014 at 02:59 AM
I figured out why the edges weren't matching up. It's peculiar, but in order to scale a terrain you must do it AFTER the the terrain gameobject is enabled.
Your answer
Follow this Question
Related Questions
heightmapWidth and heightmapHeight always equal 1 Answer
Why does assigning heightmapResolution increase the size of my terrain? 2 Answers
Ridges on terrain with lowering/raising height? 1 Answer
Unity imports heightmaps in kind of upside down order. 0 Answers
Error while trying to access a Terrain's terrainData. 1 Answer