Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 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 /
  • Help Room /
avatar image
1
Question by GrindingGoat · Mar 15, 2021 at 11:48 AM · meshgenerationminecrafthexagonchunk

Why does my Chunk generator reset the vertex positions?

I am currently working on a chunk generator for a block- based game like Minecraft, but with hexagonal blocks instead of cubes. The basic idea to generate one chunk is taking the vertices of one template block and copying them into a new mesh, adding an offset everytime, to put the blocks into the right position. And it basically works, but only with relatively small amounts of blocks like in the first picture with a size of 10x10x10 (H, W, D) blocks. alt text

But if I get to a certain amount of blocks the vertex positions seem to be reset to the chunk objects origin, so the next blocks will be generate inside the already existing blocks, (pictures 2 and 3) alt text

This is the code I use to calculate the Vertex coordinates (it's called in the Start method):


void GetBlockData() { Mesh mesh = GetComponent().mesh; blockVertices = new Vector3[mesh.vertices.Length];

     for(int i = 0; i < mesh.vertices.Length; i++)
     {
         Vector3 temp = mesh.vertices[i];
         Vector3 newVec = new Vector3(temp.x, temp.z, temp.y);
         
         blockVertices[i] = newVec;
     }

     blockUV = mesh.uv;
     blockTriangles = mesh.triangles;
     for  (int i = 0; i < blockTriangles.Length - 2; i += 3)
     {
         int a = blockTriangles[i];
         int b = blockTriangles[i + 2];
         blockTriangles[i] = b;
         blockTriangles[i + 2] = a;
     }

 }

Why does that happen? Is there anything I don't see? I literally tried everything that came into my mind to fix it, but I cant find the mistake.

chunk10x10x10.png (100.3 kB)
chunk-10x15x15.png (276.4 kB)
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 DJ_Design · Nov 18, 2021 at 02:42 AM 0
Share

I'm actually having the exact same issue.. it's so baffling would love to know if you ever figured this one out!

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by DJ_Design · Nov 18, 2021 at 10:47 AM

Hi, I found the issue to be mesh limitations inside unity. You will notice, if you remove the sides/bottom of your mesh, the chunk create further along your defined limits.

To remedy this, optimize your mesh by reducing verts, and consider splitting your mesh into separate meshes. There is also the option to do; mesh.indexFormat = UnityEngine.Rendering.IndexFormat.UInt32; after you initialize your mesh, which will gave you a TON more room at the cost of more allocation, instead of 65k you get up to 4 BILLION vertices! Enjoy.

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

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

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

Related Questions

Generating a Plane with a big number of polygons? 1 Answer

Physics.CheckSphere isn't working well 0 Answers

Easy chunk prefab creation 0 Answers

Procedural sphere defects 1 Answer

How do I generate a grid of random shapes that tile perfectly? 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