Forum rules - please read before posting.

Same-scene loading and Remember functions

Hi folks,

The 'remember' functions seem pretty straightforward, but I can't seem to get mine to work right when saving and loading to the same scene.

The example I have here is: I have a 2D Mesh Collider in a scene.  After an action (let's call it ActionA), the mesh is removed from the scene.  Pretty basic, works fine.

But I want to make sure the collider status persists across savegames,so I add a Remember Collider script to it, using the default settings.

Now I save the game, then perform ActionA, removing the collider.  Then I reload the game from within the same scene, the collider is not there, although I'm reloading to before ActionA.

However, if I leave the scene before reloading, and then reload the save from another scene, the mesh is restored as it should be.

To summarize, the Remember Collider script seems to work only when loading from another scene. I've had similar problems with other Remember scripts, always having to do with reloading from within a scene.

I'm committed to v1.46 at the moment, and I've searched the patch notes since that release, but not seen anything indicating that this needed a fix.  So maybe I'm just not understanding something about 'remember' components.

Any explanations for this rookie scripter?

Comments

  • You can see Section 9.2 of the Manual for a more complete description, but the RememberCollider component will only store the enabled state of the Collider component itself (which can be turned on and off with the Object: Send message Action provided the collider's got the _Collision component on it.

    If you're removing the collider gameobject from the scene/hierarchy, you'll need to attach the RememberTransform component instead, as this also has the option (as well as storing it's position) to store the object's presence within the scene.  You'll also need to make the object a prefab and place it in a Resources asset folder (again, see the Manual), but for simplicity you're probably better off simply disabling the Collider component or moving it out of view.
  • Thanks, I think I'm catching on. 

    But do need some clarity on the Resources folder. A few questions:

    - Is there any consequence to dragging an existing prefab from, another folder to the Resources folder? References will stay intact and it will work as usual?

    - Are there any requirements for how assets are organized in the Resources folder?  For instance, if something normally hangs out in the Models folder, can I create a Models subfolder in Resources and put it there?

    Also, moving a few select assets, as the need arises, into a Resources folder presents some organizational challenges - say, which folder should a modeler look in when searching for an asset?   Do you have any rules-of-thumb here?  Is there any reason - memory or otherwise - that we shouldn't just move, say, every single prop prefab into the Resources folder, on the chance that we might want the save system to track it?

    Thanks again.
  • These are more general Unity questions, but yes - references should stay intact, and subfolders within Resources should also work.

    The added compexity involved in this, however, is why I recommend simply hiding such objects from view wherever possible.
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.