Destructible Saver Ignoring & Remembering Destruction at Same Time

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Mackerel_Sky
Posts: 111
Joined: Mon Apr 08, 2019 8:01 am

Destructible Saver Ignoring & Remembering Destruction at Same Time

Post by Mackerel_Sky »

Hey,

I'm testing at implementing destructible saving with an enemy and it seemed to be despawning between scenes regardless of whether I killed it or not. I opened up the DestructibleSaver to take a look at what was happening. I added some Debug.Print lines to the check in RecordDestruction() to see whether the object wasn't getting ignored on destruction when the scene changes, as well as OnBeforeSceneChange().

Both cases in RecordDestruction() were called for some reason, which meant the object first remembered its destruction and then called a second time and ignored it. The print in OnBeforeSceneChange() wasn't called at all.

Do you know what could have caused this? This object was the only one in the scene with a DestructibleSaver on it.

Thanks.
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: Destructible Saver Ignoring & Remembering Destruction at Same Time

Post by Tony Li »

Hi,

How are you changing scenes?
Mackerel_Sky
Posts: 111
Joined: Mon Apr 08, 2019 8:01 am

Re: Destructible Saver Ignoring & Remembering Destruction at Same Time

Post by Mackerel_Sky »

I'm away from my computer at the moment, but I think I call Unity Scene Manager's normal LoadScene() methods when my player uses a door or something. I"LL get back to you once I have an opportunity to open the project again.
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: Destructible Saver Ignoring & Remembering Destruction at Same Time

Post by Tony Li »

Use PixelCrushers.SaveSystem.LoadScene, or manually call BeforeSceneChange beforehand. Otherwise the destructible saver won't know that it's being destroyed because the scene is being unloaded.
Mackerel_Sky
Posts: 111
Joined: Mon Apr 08, 2019 8:01 am

Re: Destructible Saver Ignoring & Remembering Destruction at Same Time

Post by Mackerel_Sky »

That fixed it, thanks!
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: Destructible Saver Ignoring & Remembering Destruction at Same Time

Post by Tony Li »

Great! Glad to help.
Post Reply