to add conditions to my conversations, but its not working as shown in the video.
I have added a variable "kaahlerKilled" to the variables tab, and then in a conversation, based on the decision taken by the player the variable is set true or false:
Screenshot 2024-01-13 at 23.02.22.png (98.26 KiB) Viewed 73834 times
But it appears that whatever I choose here the variable stays at its starting value of false and does not change..
Because when I use that as a condition the "false" path is always taken.. here is a screenshot of such a conversation:
Screenshot 2024-01-13 at 23.06.27.png (147.8 KiB) Viewed 73834 times
But in the true path if I select: "false condition action = passthrough" then the true path is taken but the first conversation block is passed/ignored
Re: Conversation conditions not working
Posted: Sat Jan 13, 2024 2:50 pm
by Tony Li
Hi,
What are the values of the Script fields on "Punish him" and "Forgive him"?
What are the Conditions on "General Akur, what has..." and "Prince Kaahler: I could li..."?
Please also see the video below. It shows how to check variable values at runtime:
Re: Conversation conditions not working
Posted: Sun Jan 14, 2024 3:03 am
by farazk86
The script field for "Punish him" is ``Variable["kaahlerKilled"] = true`` and the script field for "Forgive him" ``Variable["kaahlerKilled"] = false``.
The conditions of "General Akur, what has become," is ``Variable["kaahlerKilled"] == true``. And the conditions of "Prince Kaahler,..." is ``Variable["kaahlerKilled"] == false``.
I checked the video and tried the variable inspector during the dialogue and when Punish him was selected the runtime value changed from false to true.
But when the scene changed, the value went back to its initial value of false...
Re: Conversation conditions not working
Posted: Sun Jan 14, 2024 9:23 am
by Tony Li
farazk86 wrote: ↑Sun Jan 14, 2024 3:03 amBut when the scene changed, the value went back to its initial value of false...
I think this is the key.
Did you untick the Dialogue Manager's Other Settings > Don't Destroy On Load checkbox?
How are you changing scenes? If you're not allowing the Dialogue Manager to survive scene changes, you must change scenes using the save system and DialogueSystemSaver component.
Re: Conversation conditions not working
Posted: Sun Jan 14, 2024 9:33 am
by farazk86
I would rather the dialogue manager not be persistent and it does not need to exist in every scene of my game, only in a couple cutscene scenes and in the campaign map scene. That is why I would rather it not be DontDestroyOnLoad().
Rather than use the save system (which is also persistent) can I not call a function in c# to save the variable? and then load this variable in in the campaign map scene?
I am changing scenes via the default SceneManager.
int kaahlerKilled = PlayerPrefs.GetInt("kahler_killed", 0);
if (kaahlerKilled == 1)
DialogueLua.SetVariable("kaahlerKilled", true);
else
DialogueLua.SetVariable("kaahlerKilled", false);
it seems to have done the trick
Re: Conversation conditions not working
Posted: Sun Jan 14, 2024 10:24 am
by Tony Li
I'm glad you got that working. It might not be very scalable, though. There's no reason to save a copy of the variable to PlayerPrefs and then restore it from PlayerPrefs. This also won't work on platforms (some consoles) that don't support PlayerPrefs. If you'd like to look into why variables aren't persisting across scene changes, please start by answering the questions above.