New to Dialogue System - Variables Not Resetting

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
APineTree
Posts: 1
Joined: Sun Jun 27, 2021 4:17 am

New to Dialogue System - Variables Not Resetting

Post by APineTree »

Good morning! First of all, I just wanted to say that I am so elated to have found Dialogue System. As someone who has next to zero knowledge of coding, it's really great to be able to focus on the creative aspects of game design rather than the technical knowledge. Combined with Corgi Engine, I really feel unstoppable!

I ran into an interesting hang-up this evening, which might partially be due to my lack of technical knowledge. I followed your great tutorial on How to Run a Conversation Only Once. I was excited to use this, as I've got conversations set up with game objects that should only run once. For example, the player character can walk up to a clock, the dialogue "Tick tock" will appear, and I'd like for it to not be repeatable. Your tutorial worked as intended, but I found that when I clicked 'play' to test my game out in Unity, my variables are being stored. Unity has decided to forever remember that I talked to that clock 5 minutes ago when I was testing the game out previously. :lol:

I thought adding a script like you suggested here would work, but I've got two almost-identical scenes with the same clock. If I stay in the starting scene, I'm able to talk to the clock each time I load up to test my game. If I make it to the scene with the second clock, I'm not able to talk to it a second time (as intended), but the variable is forever recorded. Is there any way around this?

Also, is there any way to erase the variables that have already recorded? I'm up to variable TalkedToNPC4, and it would be great to start fresh.

Thank you for your assistance!
User avatar
Tony Li
Posts: 21989
Joined: Thu Jul 18, 2013 1:27 pm

Re: New to Dialogue System - Variables Not Resetting

Post by Tony Li »

Hi,

Thanks for using the Dialogue System!

Does the variable remain true when you exit play mode and then re-enter play mode?

Internally, variable values are stored in runtime memory on the Dialogue Manager GameObject. The Dialogue Manager GameObject survives scene changes. So if, during play mode, you set a "TalkedToScene1Clock" variable true in scene 1 and then travel to scene 2, the "TalkedToScene1Clock" variable will still be true. This is by design, so that when you return to scene 1 the variable will still be true, blocking you from talking to the clock again.

However, the variable value should not remain true when you exit the Unity editor's play mode and re-enter play mode. If it's still true when you re-enter play mode, then something is setting it true. Have you set up the Dialogue System's Save System and an Auto Save Load component? If so, it's possible that the Auto Save Load component is saving the variable values when exiting play mode, and then restoring them when re-entering play mode.

If the clock in scene 2 is a different clock, you'll want to use a different variable to distinguish them. A tip: You can use "." in variable names to group them into submenus in variable selection dropdown menus. For example, you could name your variables "Objects.TalkedToClock1" and "Objects.TalkedToClock2" to group them into a submenu "Objects". Or you could name some variables "Scene1.TalkedToClock" and "Scene1.TalkedToDesk" to group variables into a submenu "Scene1".
Post Reply