Page 1 of 1

Destructible Saver Ignoring & Remembering Destruction at Same Time

Posted: Fri Mar 20, 2020 8:16 am
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.

Re: Destructible Saver Ignoring & Remembering Destruction at Same Time

Posted: Fri Mar 20, 2020 9:15 am
by Tony Li
Hi,

How are you changing scenes?

Re: Destructible Saver Ignoring & Remembering Destruction at Same Time

Posted: Fri Mar 20, 2020 10:22 am
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.

Re: Destructible Saver Ignoring & Remembering Destruction at Same Time

Posted: Fri Mar 20, 2020 11:07 am
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.

Re: Destructible Saver Ignoring & Remembering Destruction at Same Time

Posted: Sat Mar 21, 2020 8:51 am
by Mackerel_Sky
That fixed it, thanks!

Re: Destructible Saver Ignoring & Remembering Destruction at Same Time

Posted: Sat Mar 21, 2020 9:07 am
by Tony Li
Great! Glad to help.