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
1
Question by Munkkeli · Jun 02, 2014 at 07:37 PM · mathproceduralchunk

Cross chunk details

I'm trying to generate trees, rocks and other details on my chunks. Currently the system only works when the chunk is placed on all positive coordinates (x > 0 && y > 0).

alt text

Like you can see from the image, the right side (x > 0 && y > 0) works well but the left side (x < 0 && y > 0) is wrong on the X coordinate.

The system works by generating a blob of stone based on the random seed, it also calculates the blobs for each chunk next to the current chunk so the blobs from the nearby chunks can continue to the current chunk if needed.

I'v been working to fix this issue for couple of days now, and if someone has a better way of doing this I would gladly hear it.

Here are the current functions used to get the decorations for each chunk:

     // Get decorations for a chunk
     private static void GetDecorations(int X, int Y, Decoration decoration, List<Decoration> decorations, ChunkGenerator gen) {
         int size = World.world.chunkWidth;

         // Get decorations for all the nearby chunks
         for (int x = -1; x <= 1; x++) {
             for (int y = -1; y <= 1; y++) {
                 GetDecoration(X + (x * size), Y + (y * size), decoration, size, decorations, gen);
             }
         }
     }

     // Get decorations for one chunk
     private static void GetDecoration(int X, int Y, Decoration decoration, int size, List<Decoration> decorations, ChunkGenerator gen) {
         System.Random rnd = new System.Random((int)(Mathf.PerlinNoise(X / 10f, Y / 10f) * 100000));
 
         for (int i = 0; i < decoration.density; i++) {
             if (rnd.Next(0, decoration.rarity) == 0) {
                 int x = X + rnd.Next(0, size), y = Y + rnd.Next(0, size);
                 decorations.Add(new Decoration(decoration.block, decoration.maxSize, decoration.minSize, decoration.density, 0, decoration.function, x, y, 138, rnd.Next(decoration.minSize, decoration.maxSize + 1)));
             }
         }
     }
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

0 Replies

· Add your reply
  • Sort: 

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

21 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

I am having trouble with the math for a rogue like dungeon generator 1 Answer

Minecraft clone, how to handle grass block colours 1 Answer

Hint joint how to configure 0 Answers

Procedural terrain pausing update with IEnumerator not working. 0 Answers

Struggling with procedural mesh math 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