Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

How to save different worlds data?

Discussion in 'Scripting' started by unity_1236alman, Apr 30, 2021.

  1. unity_1236alman

    unity_1236alman

    Joined:
    Mar 4, 2019
    Posts:
    66
    Hello guys, i'm creating a game like Terraria or Minecraft, where you can create different worlds, each one different from others. When the player quits, should i save every tree, chest and item in the world and his position, or there is a better way to handle this?
     
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    You save whatever data is necessary to recreate the scene(s). So it depends on where these tree, chest, etc, objects came from whether you'd need to save them.

    For example, if these objects are already a part of the scene itself, you don't need to include them in a save file unless something about them has changed. If they are objects which are created by the player at runtime, you'd need to save them of course.
     
    unity_1236alman likes this.
  3. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,520
    Everything that Uncle Joe says above, plus be sure to check out at least a few tutorials to understand what is involved. This is very well-understood technology so be sure you don't waste time with dead ends. I have scribbled about the basics before as well:

    Load/Save steps:

    https://forum.unity.com/threads/save-system-questions.930366/#post-6087384

    Don't use the binary formatter/serializer: it is insecure, it cannot be made secure, and it makes debugging very difficult, plus it actually will NOT prevent people from modifying your save data on their computers.

    https://docs.microsoft.com/en-us/dotnet/standard/serialization/binaryformatter-security-guide
     
    unity_1236alman and Joe-Censored like this.