Forum rules - please read before posting.

Issue with save/load with a prefab loaded at runtime

AC 1.85.5 + Unity 2022.3.62f2

Hi,
I'm loading a prefab at runtime using "Object: Add or Remove", using addressables. This object is loaded in scene A and then made persistent, since I need it in other scenes, let's say scene B.
I have two issues:

  • When I save the game in scene B, exit the game and later reload the game, the object is non loaded. My understanding is that using Remember Transform (as per manual instructions), it should be there, but it's not.
  • Since the object is persistent, if I load a game in a scene that don't need it, I need to remove the object. What's the best way to handle this? Do I need a custom script that is notified when loading a game?

Thank you.

Comments

  • I'm afraid Remember Transform components are required to be in a specific scene - it won't work if the object is persistent.

    To get around this, you'll need to either:

    1. Have the object be spawned by default, when the game begins, and hide/show it when needed via e.g. Object: Teleport Actions.
    2. Use a Global Variable to keep track of whether the object has been spawned, and use that when loading to determine if it should be re-spawned.
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.