Page 1 of 2
Have dialogue restart in specific scenarios
Posted: Tue Apr 13, 2021 11:46 pm
by soniclinkerman
In my game, the player is able to pause during dialogue. They have the option to go back to the main menu as well, but when you play again, the dialogue that was in process is still visible. Is there a way to RESTART that specific dialogue once I go back to that area?
So say I go through all Level 1 dialogue. I head over to level 2, but decide to just quit the game mid dialogue. How can I reset it so when thee player reaches that level again, it will start from the beginning?
Re: Have dialogue restart in specific scenarios
Posted: Wed Apr 14, 2021 9:33 am
by Tony Li
Hi,
If I understand correctly, would it work to:
1. Stop the current conversation when changing scenes, and
2. Don't save the current conversation state in saved games?
If so, then:
1. Add a short script like the one below to your Dialogue Manager.
2. Don't add a ConversationStateSaver to your game.
Code: Select all
using UnityEngine;
using PixelCrushers.DialogueSystem;
public class StopConversationOnSceneChange : MonoBehaviour
{
void Awake()
{
PixelCrushers.SaveSystem.sceneLoaded += (sceneName, sceneIndex) => { DialogueManager.StopConversation(); };
}
}
(Fixed typo.)
Code: Select all
using UnityEngine;
using UnityEngine.SceneManagement;
using PixelCrushers.DialogueSystem;
public class StopConversationOnSceneChange : MonoBehaviour
{
void Awake()
{
SceneManager.sceneLoaded += (scene, mode) => { DialogueManager.StopConversation(); };
}
}
(Added. Handles cases when not using save system.)
Re: Have dialogue restart in specific scenarios
Posted: Wed Apr 14, 2021 11:09 am
by soniclinkerman
For some reason, I'm getting errors when I put this in a script I made
Re: Have dialogue restart in specific scenarios
Posted: Wed Apr 14, 2021 11:52 am
by soniclinkerman
Also, just to clarify:
There might be a situation where the player pauses the game during a dialogue session. There's also a possibility they will QUIT and return back to the menu screen.
What should happen is, if they fail to complete that level, that specific dialogue should restart when they return. It would be as if they NEVER reached that conversation to begin with
Re: Have dialogue restart in specific scenarios
Posted: Wed Apr 14, 2021 1:20 pm
by Tony Li
Hi,
I fixed a typo in my post above. I also added a variation that handles the case if you're not changing scenes using the save system. (However, in general, if you're using the save system, you should change scenes using the save system.)
There are a few more details that we may need to iron out. For example, if you're using a variable like in
How To: Run a Conversation Only Once, you'll want to set that variable at the end of the conversation or whatever point in the conversation is deep enough to register as having reached/completed that conversation.
Re: Have dialogue restart in specific scenarios
Posted: Wed Apr 14, 2021 3:32 pm
by soniclinkerman
Hey Tony,
Yes, I plan for all these conversations to happen only once. What I did is use a boolean value to determine whether or not I've reached a point in the conversation that it never needs to appear again
Re: Have dialogue restart in specific scenarios
Posted: Wed Apr 14, 2021 3:37 pm
by soniclinkerman
The only issue I see now is this:
The player should be able to continue dialogue by either pressing "Z" or "Enter". SO I just added t2 "UI BUTTON KEY TRIGGER" scripts to the continue Button.
Furthermore, when the player presses "P" to pause, they can either press "Z" or "Enter" to exit or resume the game. How can I set it so pressing the "Enter" button doesn't activate the dialogue on resume. It doesn't do that when I press "Z", but does when I press "Enter"
Re: Have dialogue restart in specific scenarios
Posted: Wed Apr 14, 2021 3:51 pm
by Tony Li
Hi,
See:
How To: Pause Dialogue In Pause Menu
The operative line is:
Code: Select all
PixelCrushers.UIButtonKeyTrigger.monitorInput = false;
but you'll probably want to use the entire code in that post.
Re: Have dialogue restart in specific scenarios
Posted: Wed Apr 14, 2021 4:01 pm
by soniclinkerman
The issue is a bit different...
Whenever I push the "Z" button during dialogue and the typewriter effect is happening, I'm able to press "Return" and it suddenly starts taking the "return" button, but I turned off that script JUST to test things. I even removed that extra button trigger component, but it's still taking "Return" as a way to progress dialogue.
Keep in mind, this issue ONLY happens when I do the following.
-Have dialogue typewriter effect in progress by pressing Z
-Immediately press return in the process of the effect
Then suddenly, it takes the value of return
NOTE: When I say return, I mean Enter. I'm using mac
Re: Have dialogue restart in specific scenarios
Posted: Wed Apr 14, 2021 4:04 pm
by soniclinkerman
UPDATE
It seems if I untick "Simulate Button Click" in the UI Button Trigger, it works. I'm not too sure why that is, but it does