Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
4
Question by codex · Apr 13, 2010 at 08:03 PM · terrain

terrain rotation

Is it possible and how can i roate the terrain?

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image ivan111 · Jul 21, 2014 at 04:16 AM 0
Share

Thanks, works fine.

6 Replies

· Add your reply
  • Sort: 
avatar image
5

Answer by techstig · Mar 05, 2012 at 02:57 AM

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!

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
4

Answer by duck · Apr 13, 2010 at 08:06 PM

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.

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image flashtech · Apr 13, 2010 at 08:11 PM 0
Share

But you can rotate the Camera. But how?

avatar image duck ♦♦ · Apr 13, 2010 at 08:51 PM 2
Share

Yes of course you can rotate the camera! :-) it would be a slightly bizarre 3d engine if you couldn't.

avatar image duck ♦♦ · Apr 13, 2010 at 08:52 PM 0
Share

By modifying the camera's transform.rotation property yourself, by adding one of the pre-made camera scripts, or by Animating the camera using the animation system.

avatar image
3

Answer by ChristmasEve · Sep 29, 2017 at 03:45 PM

I know this is a very old question but the answer is, SURE you can rotate your terrain :) 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 ?? :) 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[i].position=new Vector3(1-trees[i].position.z,0,trees[i].position.x);
             trees[i].position.y = td.GetInterpolatedHeight(trees[i].position.x,trees[i].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);
         }
     }
 
Comment
Add comment · Show 7 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image maxpleaner · Oct 04, 2017 at 10:16 PM 1
Share

could this be modified to support an arbitrary rotation on any axis?

avatar image Dremand · Feb 16, 2018 at 05:12 PM 0
Share

Aw man it got me excited , I put the script in and realized it doesn't slowly rotate.. Just 90 degrees at a time. haha. Cool stuff but I want it to slowly rotate. Probably not possible eh?

avatar image astracat111 Dremand · Aug 05, 2018 at 04:56 PM 0
Share

It doesn't because it re-drawing/rotating the heightmap.

avatar image ughdeeb · Dec 02, 2018 at 02:30 AM 0
Share

Hi,

Noob here.

I've added your script to my terrain but do not see how to click "Rotate 90 Deg" in your menu multiple times. Can you provide more information?

Thanks!

avatar image ughdeeb ughdeeb · Dec 02, 2018 at 02:44 AM 0
Share

ah never$$anonymous$$d i see it up on the menu now. is there any way to duplicate just the one terrain? I have dupilicated a terrain and trying to rotate it to piece it together, but when i use your tool both terrains rotate 90 degrees.

avatar image ollaxe · Mar 19, 2019 at 08:49 AM 0
Share

This script is great, although it rotates the trees the wrong way for me (90 degrees in the other direction). I don't know if it does this for other parts of the terrain since I'm only using trees, but it was easy to fix. For anyone else experiencing this problem, just replace line 34 with this:

 trees[i].position = new Vector3(trees[i].position.z, 0, 1 - trees[i].position.x);
avatar image sjameselvis · Oct 04, 2019 at 06:52 PM 0
Share

Sorry for replying on such an old question, but what do I do with the script? where do I have to put it so that it works?

avatar image
1

Answer by Cornelis-de-Jager · Dec 02, 2018 at 04:06 AM

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.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image richardgengle · Oct 02, 2020 at 12:15 PM 0
Share

it seems that attaching the terrain to a game object and trying to rotate it yields odd results... often translations

I am trying to get a ball to roll down a bumpy hill... so i think i need a work around to have both a hill , and a bumpy road

avatar image
0

Answer by discoelf · Oct 08, 2011 at 07:59 AM

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 :)

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image aneeshJoshi · Dec 20, 2016 at 12:43 PM 0
Share

The problem with that is that the render texture is highly pixelated

  • 1
  • 2
  • ›

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

14 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Make a simple tree 1 Answer

deformation terrain real time for begginers 0 Answers

Weird Shadows 1 Answer

Import problem with Blender3d 2 Answers

Import assets from older unity,How do I import the “terrain” assets in the new unity? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges