Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
0
Question by Lord Simpson · Apr 03, 2012 at 12:15 PM · terrainproceduralheightmapheight

Best way to get terrain positions from a given height range

Hi, I'm attempting to make a procedural system that will add features to a terrain based on height at runtime e.g. ports near water (height between say 15,20), castles on mountains (200+) etc,

I'm not completely sure how to go about it. My current idea is to get the height map from the terrain, run through every pixel and test it against the values and if it is in the range add a vector representing it in world space to a list.

Then randomly select values from this list to add an object if there is room.

This feels like a very brute force way of doing it even thought its unlikely to happen very often in game (doubt it will happen more then once every few minutes since it will only run when a new terrain "Tile" is generated) i was wondering if there are any better solutions / some sort of plane-terrain intersection method that could be used to make the process run smoother.

Any ideas would be appreciated.

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by GutoThomas · Apr 03, 2012 at 02:23 PM

Why don't you launch a Raycast on -Vector3.up from an object wich is located above the scenario and check the position of the hit point? This way you can check the Y position of the hit point and calcule when add a certain map asset. If you need some help at scripting of this just let me now. (:

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 Lord Simpson · Apr 03, 2012 at 03:34 PM 0
Share

This doesnt really help as i know how to get the height at a point, im trying to get all the points with a height not the height of a point.

avatar image
0

Answer by ChristmasEve · Apr 16, 2015 at 05:17 AM

I know this post is from 3 years ago but in case you, or anyone else, is interested in a good answer, you can't just say "give me all the points that are within my port range or my castle range". If you have a function give you all the heights in your "castle" range, for example, they're going to be all over the place; you probably won't get what your looking for--an area large enough to lay down a castle, for example. My best suggestion is Paint Height tool for Terrain (second tool button from the left for your terrain object). Then, hold shift to sample a terrain height at your chosen destination and then you're going to have to "paint" the height of the area around it to flatten it enough (at that height) so you can place a castle, etc. The kinds of natural looking "fractal" terrains we all use are much too bumpy to just place such a large object within one of your height ranges unless you manually edit it.

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

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Problem with heightmap and terrain height maxing out at 10000, proportions *Solved* 0 Answers

Mesh based on noise 1 Answer

Terrain height map influences ocean wave heights? 2 Answers

How to seamlessly tile terrains 0 Answers

Is it possible to generate a high-poly spherical model from a mercator-projection heightmap? 1 Answer


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