Page 1 of 1

DestructibleSaver

Posted: Thu Sep 30, 2021 3:39 am
by SealDev
I have a game with a position saver on the player as well as destructiblesaver on collectibles.

If I restart the game with the player left exactly at the location of a collectible, it collects it again (running functions like playing the collect SFX). However thankfully since I keep track of score as a dialogueSystem variable, you can't cheat by collecting the same coin over and over to infinity.

I suspect this happens because when you load the game in the first few frames you have time to collect something until it gets deactivated by the save system.

Question: is there a way to load the game at the position of a collectible that was already collected without playing the sounds again?

Re: DestructibleSaver

Posted: Thu Sep 30, 2021 8:03 am
by Tony Li
Hi,

You could disable the player's collection ability until the saved game data has been applied. One way to do this:

1. Set the player's collection ability inactive at design time.

2. Add a Dialogue System Trigger to the player, and set it to OnSaveDataApplied. Configure Actions > OnExecute() UnityEvent to enable the ability.

The Dialogue System Trigger will run the OnExecute() event after the save data has been applied. Or, if you're playing the scene directly in play mode without loading a saved game or coming from another scene, it will run OnExecute() after an equivalent number of frames as loading a saved game would take.

Re: DestructibleSaver

Posted: Thu Dec 16, 2021 12:21 pm
by SealDev
No OnSaveDataApplied?

Re: DestructibleSaver

Posted: Thu Dec 16, 2021 1:16 pm
by Tony Li
Can you back up your project and update to a more recent version of the Dialogue System? OnSaveDataApplied was added in version 2.2.17 at the beginning of last summer.

Re: DestructibleSaver

Posted: Thu Dec 16, 2021 3:17 pm
by SealDev
I have tried only importing scripts, however it adds a huge burden for my system and slows the project down (time it takes to enter/exit play mode)

Which are the few scripts I need to import for OnSaveData applied?

Would the 4 DialogueSystemTrigger scripts be enough?

Re: DestructibleSaver

Posted: Thu Dec 16, 2021 5:40 pm
by Tony Li
Are you saying that updating to version 2.2.22 increases the time it takes to enter/exit play mode?

It shouldn't, unless there's an error in your project. Are there any errors or warnings in your Console window?

You can try importing the 4 DialogueSystemTrigger* scripts, but I haven't tested this so I don't know if it has other dependencies.

Re: DestructibleSaver

Posted: Thu Dec 16, 2021 5:58 pm
by SealDev
For some reason the more script files I add, regardless of source (even from other assets) makes entering/exiting play mode slower and slower. It's not limited to the Dialogue System

Re: DestructibleSaver

Posted: Thu Dec 16, 2021 6:09 pm
by Tony Li
If you're on Unity 2020.x, try backing up your project and updating to the latest version of 2020. Earlier versions had lots of performance bugs.