Spawned Object Manager Duplicate Objects

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
EpicMcDude
Posts: 14
Joined: Fri Sep 22, 2023 5:05 pm

Spawned Object Manager Duplicate Objects

Post by EpicMcDude »

Hello!

I've searched this forum for answers and there were a few people trying to do what I'm after, which is object persistence between scenes but I can't seem to get there.
Right now I have an Apple with a Spawned Object component that I pick up and destroy in the scene. I have a Spawned Object Manager with a unique key and the Apple prefab dragged from my Prefabs folder onto the "Spawned Object Prefabs".

When I save and load, the Spawned Object Manager seems to instantiate 2 clones and the original Apple prefab on the scene exists again even though it was destroyed, now there's 3 Apples! :D
I tried using Destructible Saver to check when it's destroyed but that didn't work.

Could you point me in the right direction? Thank you!
User avatar
Tony Li
Posts: 21069
Joined: Thu Jul 18, 2013 1:27 pm

Re: Spawned Object Manager Duplicate Objects

Post by Tony Li »

Hi,

Is an Apple in the scene at design time? If so, you could remove the Spawned Object component and only add a Destructible Saver. Set a unique key.

If the player can pick up and drop Apples arbitrarily, it doesn't need a Destructible Saver. Set the Spawned Object component's Despawn Mode to OnDestroy if you actually destroy the GameObject when the player picks it up. Set Despawn Mode to On Disable if you deactivate the GameObject when the player picks it up. Also make sure you have only one Spawned Object Manager in the scene.

If that doesn't work, are there any errors or warnings in the Console window?
EpicMcDude
Posts: 14
Joined: Fri Sep 22, 2023 5:05 pm

Re: Spawned Object Manager Duplicate Objects

Post by EpicMcDude »

Tony Li wrote: Fri Sep 22, 2023 8:34 pm Hi,

Is an Apple in the scene at design time? If so, you could remove the Spawned Object component and only add a Destructible Saver. Set a unique key.

If the player can pick up and drop Apples arbitrarily, it doesn't need a Destructible Saver. Set the Spawned Object component's Despawn Mode to OnDestroy if you actually destroy the GameObject when the player picks it up. Set Despawn Mode to On Disable if you deactivate the GameObject when the player picks it up. Also make sure you have only one Spawned Object Manager in the scene.

If that doesn't work, are there any errors or warnings in the Console window?
Ah right, the Apple that already exists in the scene just needs a Destructible saver, that solved that!

But for the duplicate issue, I've sent you a YouTube link via PM so you can see the details on the components and what's happening, I believe I'm doing everything by the book but as is often the case I'm probably doing something wrong.
I'm saving and loading with ES3, and I've tried using the ES3 Prefab component and not using it, nothing changes.
It only creates instances with the Spawned Object Manager component enabled.

One thing I didn't capture in the video is that if I pause the Editor and run it frame by frame during the load sequence, one Apple gets instantiated after 1 frame as I set it to be in the Save System component, but then another one gets instantiated in the next frame. Yet this only happens with Spawned Object Manager component enabled, with it off, nothing gets instantiated.
Post Reply