Forum rules - please read before posting.

How to retain object locations after scene switch

edited February 2020 in Technical Q&A

Edit: I think I've fixed this by using the "Auto-add Save components to GameObjects" feature in the AC Game Editor's Settings tab. If this is not the whole story or not the right way to do this, please let me know.

Hi,
I've been working on my first small game using AC, and have run across an issue that I can't seem to put together what I've learned to figure out.

My game has several scenes that are switched between to solve the puzzle. You collect items in several rooms, and once you've collected everything you need, you finish the game.

Currently, things are working well except for one thing. If you collect an item in one scene (eg collect Salt in the Kitchen), the Salt disappears (ie Object Transport to Offscreen). However, if you leave the scene and return (eg go to Bedroom then go to Kitchen), the Salt is back in the Kitchen.

Here's a video showing the issue I'm having:

What's best practice for fixing this (ie location/visibility should be retained throughout scene changes)?

Thanks in advance for any help.

Gaius

Comments

  • Only a few minutes after this, I remembered the "Auto-add Save Components to GameObjects" function. I didn't connect the dots between this and the scene switch issue I described above, but figured I'd give it a try after reading a few more posts here that mentioned "Remember".

    This seems to have added what I need to save the information between scenes.

    Sorry to waste anyone's time! Let me know if this wasn't the right way to handle this.

  • Welcome to the community, @gaius.

    AC's save system works by flagging objects with "Remember" components to match the kind of information you want to be saved.

    For example, you can save a sprite's visibility with the Remember Visibility component, or save it's position (Transform) with the Remember Transform component.

    As you've found, the Auto-add Save Components to GameObjects button will indeed go through your game and attempt to add all of the necessary components automatically.

    However, as this is an automated process, there may be instances where it doesn't quite cover all your needs - so it's important to be aware of how the Remember system works so that you can add specific things manually if necessary.

    For this, see the Manual's "Saving and loading overview" chapter - particularly "Saving scene objects". This should bring you up to speed on things, but just ask here if you have any more questions or issues about it.

  • Perfect. Thanks, Chris.

    I'm just getting used to the Unity terminology, and now understand better what a "Component" is than when I read through the manual.

    I'll read through that section again more thoroughly so I can understand & fix anything that doesn't properly add the components.

    I appreciate your time giving me that insight and reference!

  • No problem. While AC does aim to be as accessible as it can be to newcomers, it does need a general understanding of Unity's core concepts.

    If you're just getting started with both AC and Unity, I'd recommend following the 2D tutorial, as it's geared towards newcomers more than the other ones.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.