Page 1 of 1

Dialogue System Trigger - OnLoad ?

Posted: Sun Nov 29, 2015 3:33 pm
by mandi
Hello Tony,
I have one problem with the design approach to making saves. Namely, let me present it.

I have a bunch of characters, which are affected by an empty gameobject with a trigger. This object has 2 components (my own; but I may use Dialogue System Trigger as well - I tested it), which do 2 things:
1. First, one of that components sends a message that makes all characters (added it to array) sleep on start of the game.
2. Second, the other component sends a message that makes all characters wake up if the player enters the trigger attached to that gameobject.

I can use variable to control whether the action of each components should be run, but the problem is that the action that is to be executed on start (the first component), will be executed anyway, provided I restart the game - because if I load saved game after restarting the game, I am not reloading the scene - just applying stored data. How to remedy this? I don't want to restart the entire scene every time I load, because I expect the player may need frequent loads. Is there something like OnLoad, a trigger via which I could revert what is happening OnStart? I would love to have Dialogue System Trigger to have this kind of trigger.

Best,
Artur

Re: Dialogue System Trigger - OnLoad ?

Posted: Sun Nov 29, 2015 4:54 pm
by Tony Li
Hi Artur,

What if you add an OnApplyPersistentData method to your component? Something like this:

Code: Select all

public class YourClass : MonoBehaviour {

    void Start() {
        MakeAllCharactersSleep();
    }
    
    void OnApplyPersistentData() {
        MakeAllCharactersSleep();
    }
}
Whenever you apply saved data, it will act the same as start.

Re: Dialogue System Trigger - OnLoad ?

Posted: Sun Nov 29, 2015 5:59 pm
by mandi
Tony,
thank you very much! I think I will make a custom PD component which will enable me to send a message during OnApplyPersistentData. This way I will be able to enable a component that will check against a Lua Variable if characters should sleep or not... this way I can automate things a bit. Not as fast as direct call, but I think I will be able to use it in cases other than characters sleeping, I mean other situations where things triggered on start need to be reverted, provided a Lua variable condition is met.
Tony, thank you again!
Best!