Search Unity

  1. Unity 2020.1 has been released.
    Dismiss Notice
  2. We are looking for feedback on the experimental Unity Safe Mode which is aiming to help you resolve compilation errors faster during project startup.
    Dismiss Notice
  3. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Customization through exchange of child objects and progress saving

Discussion in 'Scripting' started by marzipano, Jul 2, 2020.

  1. marzipano

    marzipano

    Joined:
    Dec 27, 2019
    Posts:
    1
    I'm pretty new to Unity and still figuring out how Game Objects are referenced and accessed. So far I've been successful in narrowing down the problems I'm trying to solve, but now I need some advice on what would be best practice. I'm not providing any code, nor am I looking for specific code snippets (if you happen to have something in mind, I would be glad if you'd shared it):

    I'm having a main game object and my idea is to change its appearance by swapping its child objects with other models (upgrading the game object). I've found a script that achieved that (well, not entirely. I managed to add a new child, but the old one didn't get destroyed..., but this is something that could be solved, I guess).

    Now I want to do a game where you constantly have to start over from the beginning, but keep the progress you have made in order to go farther each time.

    My first idea was to do a retry button and just reload the scene, but then everything was set to the original state and all progress was lost. I've found solutions for static variables, DontDestroyOnLoad but this didn't really work. Yet I'm seeing a few different approaches, that I would like to test:

    1. Not reloading the scene at all, but instead just setting the Game Object's location and rotation to the starting point (this would only work for 1 Level, which would be fine for now)

    2. Loading the Player Object just once in a Scene which will never be visited again.

    3. Loading the Parent Object in each scene and "fetching" the right childs. Let's say my Game Object has 5 parts that can be upgraded in 3 Steps. So I was thinking about an array that would store the values of the current upgrade level of each part and load the corresponding models.

    Can you tell me, from what I have provided, what would be the best approach here?

    Thanks.
     
  2. raarc

    raarc

    Joined:
    Jun 15, 2020
    Posts:
    163
    you can look into serialization and create a save load system. You can save the progress you want to keep when you die and then when you restart the scene you load from the serialized file whatever information you want to be kept.
     
unityunity