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 stulleman · Sep 14, 2014 at 08:59 PM · terrainchunks

Chunk position algorithm

Hello, I'm making a Minecraft clone but I'm a bit stuck right now.

So first this is what I want to do:

alt text

My chunks are 16x16x16 big and I have 10x10x10 loaded chunks.
Because I don't want to instantiate a new Chunk every time, I thought I could "recycle" the old ones.

So when a Chunk gets out of the view range, it is clear that on the other side is missing one. But I can't seem to find a solution of how to compute the new position. Especially when the player walks diagonal.

Right now I'm storing all 10x10x10 Chunks in a static list.

Maybe even that's not the best solution.

Please let me hear what you think.

minecraft clone.png (467.9 kB)
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
0

Answer by Cherno · Sep 14, 2014 at 11:34 PM

Do you actually need to move or instantiate any chunks? I think it's perfectly fine to have all chunks in any position in thegame world, like 0,0,0, and have the 10³ chunks instantiated at game start. After that, it's just a manner of changing a chunk's vertex positions instead of the chunk itself.

Comment
Add comment · Show 4 · 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 AlucardJay · Sep 15, 2014 at 02:29 AM 0
Share

I'm curious as to how floating point error may creep in just moving the vertices. Even though when the chunk gets 'moved', the vertices are reassigned anyway so why not.

At the moment, this is not a question more than a theory discussion. Without knowing how your chunks are managed, it is impossible to answer. For example : your world generator makes a grid of chunks :

 for ( Z loop )
     for ( X loop )
         worldPos = Vector3( X * tileSize * chunkSize, 0, Z * tileSize * chunkSize );
         worldChunk[x,y] = Instantiate( chunk, worldPos, ....

then it would be a matter of : where is the player in the world; what chunks around the player should be showing; move chunks accordingly; update moved chunks with new position information. Then working out an algorithm to return what chunk the player is standing on, and what are the 8 chunks surrounding that.

avatar image stulleman · Sep 15, 2014 at 04:41 PM 0
Share

Yeah I have to apologize for this question. I really didn't see the obvious and got it working now.

But to come to the point of not moving the chunks, but ins$$anonymous$$d add an offset to the vertices. Does that really make any difference?

avatar image Cherno · Sep 15, 2014 at 05:32 PM 0
Share

Well, since the vertex coordinates are updated anyway, wether they change or not, I see no reason to change the chunk object's transform.position at all.

avatar image stulleman · Sep 15, 2014 at 06:07 PM 0
Share

Okay it seems logic, but it would require a major rewrite of my code, and I don't know if it's worth the pain.

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

24 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

Related Questions

Import a 513x513 Texture2D (heightmap) 0 Answers

How Do I Fix My Grass? 2 Answers

Make a simple tree 1 Answer

Terrain Chunk loading 1 Answer

Correcting normals along chunk edges 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