terrain rotation

Is it possible and how can i roate the terrain?

1 Like

I was just looking for this myself. After playing with it a bit I was able accomplish this with the help of Photoshop:

  • Select Terrain
  • On the main menu choose Terrain->Export Heightmap - RAW

Settings:

  • Depth:16bit
  • Byte Order: I chose Win for since I’m on windows… Don’t know how this works out on Mac.

Keep note of the texture size. You will need this in photoshop.

  • Open Photoshop if you haven’t already.

  • Choose Open and browse to your file.

Settings should be:

  • Width:[Same as you noted before]
  • Height:[Same as you noted before]
  • Channels:1
  • Depth:16bits
  • Byte Order:Whatever you selected (I chose Win)
  • Header Size: 0 bytes

Hopefully at this point you are looking at a greyscale image. Now rotate, mirror, or modify as you please. When done, save as a .RAW and choose 16bit for depth.

Keep in mind that Unity will be looking for a square heightmap. If you rotate anything other than increments of 90deg, you will need to fill in that empty space with something…

Back in Unity, with your terrain selected choose Terrain->Import Heightmap - RAW. If all goes well your terrain should be rotated.

Hope this helps!

No, you can't rotate the terrain. It's not possible to tilt it, or to rotate it around the Y axis.

This is largely due to the many optimisations built-into the terrain engine code, which rely on it maintaining a fixed orientation.

I know this is a very old question but the answer is, SURE you can rotate your terrain :slight_smile:
Here is an Editor script that rotates your terrain 90 degrees clockwise. It handles the terrain itself (heightmap), the splat map, detail map AND trees. The only thing it does not handle are your GameObjects that you’ve added to it. It wouldn’t be that hard to implement transforming the game objects too though. The other thing is, this script requires your terrain be square. I’ve never even tried to generate a non-square terrain… Can you even do that ?? :slight_smile: So, by clicking “Rotate 90 Deg” in your menu multiple times, you can achieve 4 different transformations of your terrain. Pressing it 4 times will return it to the original orientation. It’ll take 10-20 seconds per rotation.

[MenuItem ("Game Tools/Rotate 90 Deg")]
    static void rotate() {
    	int i,j;
    	var ter = Terrain.activeTerrain;
		var td=ter.terrainData;
		
		//rotate heightmap
		var hgts=td.GetHeights(0,0,td.heightmapWidth,td.heightmapHeight);
		var newhgts=new float[hgts.GetLength(0),hgts.GetLength(1)];
		for(j=0;j<td.heightmapHeight;j++) {
			for(i=0;i<td.heightmapWidth;i++) {
				newhgts[td.heightmapHeight-1-j,i]=hgts[i,j];
			}
		}
		td.SetHeights(0,0,newhgts);
		ter.Flush();
		
		//rotate splatmap
		var alpha=td.GetAlphamaps(0,0,td.alphamapWidth,td.alphamapHeight);
		var newalpha=new float[alpha.GetLength(0),alpha.GetLength(1),alpha.GetLength(2)];
		for(j=0;j<td.alphamapHeight;j++) {
			for(i=0;i<td.alphamapWidth;i++) {
				for(int k=0;k<td.splatPrototypes.Length;k++) {
					newalpha[td.alphamapHeight-1-j,i,k] = alpha[i,j,k];
				}
			}
		}
		td.SetAlphamaps(0,0,newalpha);
		
		//rotate trees
		var size=td.size;
		var trees=td.treeInstances;
		for(i=0;i<trees.Length;i++) {
			trees<em>.position=new Vector3(1-trees_.position.z,0,trees*.position.x);*_</em>

trees.position.y = td.GetInterpolatedHeight(trees_.position.x,trees*.position.z)/size.y;
}
td.treeInstances=trees;*_

* //rotate detail layers*
* var num=td.detailPrototypes.Length;*
* for(int k=0;k<num;k++) {*
* var map=td.GetDetailLayer(0,0,td.detailWidth,td.detailHeight,k);*
* var newmap=new int[map.GetLength(0),map.GetLength(1)];*
* for(j=0;j<td.detailHeight;j++) {*
* for(i=0;i<td.detailWidth;i++) {*
* newmap[td.detailHeight-1-j,i]=map[i,j];*
* }*
* }*
* td.SetDetailLayer(0,0,k,newmap);*
* }*
}

There are several answers here already, but they are of different opinions and I believe if combined will give a good answer.


Short Answer - Yes you can, but you shouldn’t.

Long Anser -
As demonstrated by @techstig you can indeed to it. However as mentioned by @duck you really shouldn’t because the terrain is optimized for a performance. Also mentioned in the comment section of duck’s post it is better to simulate rotation. This can be done by rotating the Camera or even rotating everything except the actual terrain.

For example if you put everything under a singular object, you can have a simple transform.rotate() to rotate everything., since everything will be a child of this object.

You cannot rotate the terrain, however, you may be able to pull off the illusion of rotated terrain using Assets->Create->Render Textures (Pro Version)

You can render texture from what a camera sees onto a plane of terrain and rotate the plane. It isn't perfect as it is clearly 2D at certain angles, but at the right angle or with the right use it may work.

I really wish they'd introduce terrain that can rotate too :)

What i have been able to do is scale 2d array values to make a slope.

like , psuedo code

for i…

for j [in for i]

terain height[ij] = 1-1/[max ct]
ter.sethts