Hi there,
I have followed the tutorial:
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:
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:
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
Conversation conditions not working
Re: Conversation conditions not working
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:
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
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...
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
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
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.
Thanks
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.
Thanks
Re: Conversation conditions not working
I believe I found my answer in : https://pixelcrushers.com/dialogue_syst ... pting.html
I am saving the decision to a PlayerPref and then in the Awake() of my campaign map scene I am setting variable like:
it seems to have done the trick
I am saving the decision to a PlayerPref and then in the Awake() of my campaign map scene I am setting variable like:
Code: Select all
int kaahlerKilled = PlayerPrefs.GetInt("kahler_killed", 0);
if (kaahlerKilled == 1)
DialogueLua.SetVariable("kaahlerKilled", true);
else
DialogueLua.SetVariable("kaahlerKilled", false);
Re: Conversation conditions not working
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.