• 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
0
Question by AVividLight · Apr 17, 2012 at 07:54 PM · c#heightmap

Understanding the generation of a basic heightmap/colormap

Message to Moderator: This is a different question than the one I posted earlier, please don't delete this!

Hey guys,

Basically, I want to know how to create a terrain through code. Just something simple, like the image bellow. It needs to be two flat levels, and have a strait (strait up and down, not strait across the level) cliff separating them. Also, if it's possible, I would like it to also generate a riverbank and waterfall that stretches to the sea (almost exactly like the picture bellow).

Picture

I am sorry for all the topics I've posted about this recently, but I don't understand it, and would really appreciate some help. Thanks again for all your help and comments!

-Gibson

P.s. The picture is from a game that I'm remaking, so please pardon the little houses and such.

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by IgnoranceIsBliss · Apr 17, 2012 at 10:51 PM

The easy answer is try. There is no single solution to this problem (although I've previously shown you how to get it all into Unity itself at http://answers.unity3d.com/questions/241010/how-to-procedurally-make-a-super-simple-heightmap.html ).

This is a fundamental feature of your game, so it's worth figuring out this part yourself - it's not really fair to ask someone else to give you a pre-packaged, complete terrain generator. It's a lot of work and it needs to be customised for each game.

And it's actually a lot of fun if you are a developer at heart.

If you then run into specific problems with your terrain generator, feel free to ask. People can easily deal with the smaller problems.

But these also aren't unity-specific questions. Perhaps you'll get better answers at general game-development forums.

But if you want a quick introduction...

Start with the height map, because the textures you use will most likely depend on the heights.

  • Start from the sea (low height values) and then smoothly increase the height in one direction (so you raise up out of the water and onto dry land).

  • Create random hills. You usually do that by adding random offset to the points you made in the previous step, then smoothing them out again when you are done. The most popular approaches use fractal noise (which tend to generate soft, realistic hills), but you don't have to go that far if you don't want to.

  • Randomly create your rivers by digging them into the terrain. Make sure you start from one end and work towards the ocean.

  • You will need to go through and use some technique to make sure every piece of your map is accessible. This is a little difficult, but could be done with some kind of 'flood fill' algorithm. If an area is inaccessable, add a bridge or ramp.

  • Then 'colour' your map by using different textures. If it is under-water, use sand. If it is above water, use grass. If it's half way in between, blend the two. If it is paricularly steep, use rock.

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 AVividLight · Apr 17, 2012 at 11:01 PM 0
Share

Thank you for the tips, but I should clarify, I am not asking for some code, I'm asking for some help with understanding how to write it. I don't know what kind of functions to use, or even the extension for a heightmap file. I would appreciate it if you could help me in that way. - Thanks again for this insightful answer! -Gibson

avatar image AVividLight · Apr 19, 2012 at 09:59 PM 0
Share

Do you know what functions I will need to use to actually create the heatmap?

avatar image IgnoranceIsBliss · Apr 30, 2012 at 12:50 AM 1
Share

You just need basic program$$anonymous$$g knowledge, not specific functions. There isn't a '$$anonymous$$akeTerrain' function.

You'd need to create an array that contains your heightmap (for example, a float[,] ) and then fill it with the values you want to make up.

Get yourself some grid paper and make it up yourself WITHOUT a computer on a very small terrain. Write numbers representing different heights in the grid. See what works to make a terrain in the style you want.

Once you've got the math worked out, just write down the rules governing how you did it and start writing the code based on that.

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

6 People are following this question.

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

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

How to procedurally generate a super simple terrain 1 Answer

Renderer on object disabled after level reload 1 Answer

Why don't the terrain size I set in Terraindata match the size of the terrain that is created ? 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