DestructibleSaver

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
SealDev
Posts: 85
Joined: Thu Jun 24, 2021 5:45 am

DestructibleSaver

Post 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?
User avatar
Tony Li
Posts: 21981
Joined: Thu Jul 18, 2013 1:27 pm

Re: DestructibleSaver

Post 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.
SealDev
Posts: 85
Joined: Thu Jun 24, 2021 5:45 am

Re: DestructibleSaver

Post by SealDev »

No OnSaveDataApplied?
Attachments
2.png
2.png (23.02 KiB) Viewed 564 times
User avatar
Tony Li
Posts: 21981
Joined: Thu Jul 18, 2013 1:27 pm

Re: DestructibleSaver

Post 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.
SealDev
Posts: 85
Joined: Thu Jun 24, 2021 5:45 am

Re: DestructibleSaver

Post 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?
User avatar
Tony Li
Posts: 21981
Joined: Thu Jul 18, 2013 1:27 pm

Re: DestructibleSaver

Post 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.
SealDev
Posts: 85
Joined: Thu Jun 24, 2021 5:45 am

Re: DestructibleSaver

Post 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
User avatar
Tony Li
Posts: 21981
Joined: Thu Jul 18, 2013 1:27 pm

Re: DestructibleSaver

Post 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.
Post Reply