Advertisement

3D editable world saving and generating in Unity.

Started by December 07, 2014 10:46 PM
1 comment, last by LordRhys 10 years, 1 month ago

I'm planning to create a game in Unity with a simplistic 3D world with resources.

The resources placed in the world can be gathered and they will be removed from the terrain.

Now my question is what would be the best way to save this kind of data.

There will be many different maps and some of them will be playable multiplayer.

The world/terrain itself doesn't have to be saved this will be the same each time for levels.

But the resources placed on top for example trees and ores need to be saved.

So when you close the game and load it the resources already collected need to be gone.

I thought about giving each object a UUID and have a list of them in order and then just have 0-1 in a text file or something if it's collected or not.
But I wanna be able to just create the world in unity and place all resources on the correct place etc in unity.

I'm looking for the best way to save and load the resources and then load them in when the level is loaded on the proper place if they aren't collected.

For the terrain itself is it fine creating a big model for it or is it better using unity terrain?

It doesn't need to be saved only the resources.

if you talk about multiplayer, you are most probably talking about a client-server system. In this case a Database would be the best choice, both because for performance reasons if your world grows bigger, and because of concurrent access and modification to the same data. A database can handle this for you (if you use it properly), in a file based system you need to come up with ways of handling it yourself.

for local you could pick a lightweight database just to make sure single- and multiplayer uses the same code, or go with a simple xml file.

Something to think about is how to make cheating a little bit harder when resources are placed with the help of this file (can't stop it really, but if every dork can just open the file and edit it, might also be a little bit to easy).

Advertisement
Since yousay your using Unity the answers are pretty much right there, you can store the resource locations in an XMl file, use Unity Scripting to read the locations and place them in the world, and also use Unity Scripting to remove them and when you save write them to your save file in XML format. When you load you read the saved XML instead of the base XML. This will also allow you to eventually have a persistent world where resource nodes can grow back over time and be harvested again.

This topic is closed to new replies.

Advertisement