• 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 janzdott · Feb 04, 2013 at 11:25 PM · savesavingdatacustomminecraft

Advice about saving complex data (Minecraft-like game)

Hey everybody. Lately, I've been writing a voxel engine for Unity, very similar to Minecraft. It's coming along very well, and I'm writing the engine separately from my game, so I will release the engine on the asset store when I feel it's ready.

I've been thinking about how I will be saving data. The world is generated pseudorandomly, meaning that the same seed will generate the same world every time. Because of this, only the blocks that are changed by the player must be saved. The world is broken up into smaller "chunks" of terrain. Like Minecraft, the world is infinite, and chunks are generated as the player explores.

Minecraft saves chunks in "regions", which are just large groups of chunks. I'm thinking that would be a good approach. Each block is stored as a byte and can be accessed via a 3 dimensional byte array. So I need to save which blocks have been changed in each chunk. But I've never had to save any custom data. I've always used playerPrefs, but I don't think that's an option here. I know you can use xml files to save some things, but I don't know much about that. I was just wondering if anyone had some good ideas? Any help would be greatfully appreciated.

Comment
Add comment · Show 3
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 DaveA · Feb 04, 2013 at 11:33 PM 0
Share

A fan of voxels, wondering how your's will be different/better than those on the Asset Store now? Although this may be a discussion for another forum perhaps.

avatar image janzdott · Feb 05, 2013 at 04:16 AM 0
Share

I'm making the engine VERY easy to use. Everything to get the game running will come by default. (Import the package and click "create new world". Then you can click play, and it will work). And engine settings and world data are all be changeable in the editor, without touching code. Just a few mouse clicks to add new types of blocks, and to assign textures to blocks. Custom blocks (not cube shaped) can be added just by specifying a mesh. VERY easy terrain generation, where you can create and change parameters right in the editor. There will also be the option to write your own terrain generator if the default one doesnt provide enough functionality. It will most likely be compiled into a dll, so C# or unityscript can be used. I will also include full documentation. I'm making this for a mobile game, so its optimized but no fancy graphics, sorry :/ I will release free versions as I make more progress. But the finished product may or may not be free.

avatar image Fattie · Feb 05, 2013 at 06:45 AM 0
Share

you need UNity Serializer, which everyone uses. amazingly it is free. google Whydoidoit Unity Serializer

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by DaveA · Feb 04, 2013 at 11:33 PM

The format doesn't matter. If this is not web-based, you can use .NET file and stream classes to read/write whatever data you like (binary I would think).

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 janzdott · Feb 05, 2013 at 03:54 AM 0
Share

Well, for each chunk that has been modified, I need an array of the changed blocks. The array will have to hold the blocks' positions and a byte for what kind of block it is. And I need very fast access to individual chunks that have been saved. It also has to be able to check if save data exists for that chunk or not. If I were to write a binary data file, how would this work?

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

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

11 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

Related Questions

Saving problem unity project 5 Answers

Loading a list into unity 0 Answers

How can I make this script save and or load what I do in my game?? 2 Answers

How do I save and retrieve ordered data? Can I do this with an array? 1 Answer

Saving Project causes Unity Game Engine to lose focus. Why? 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges