Hello!,
I've run into an awkward situation regarding pausing my game during conversations.
I have a fairly standard conversation which I want to end in one of two ways. The player has the task to bring an object to an NPC. If they bring the right object and present it to the NPC then they succeed, otherwise they fail. When they do succeed, the NPC leaves the area by means of the game fading to black briefly and then back in with the monster having disappeared. I'd like the game to be paused throughout the conversation and sequence to prevent anything else triggering and messing up.
At present I am doing this by ending the conversation then beginning a short sequencer cutscene with the following instructions:
SendMessage(StopTime, , Game Manager);
Fade(out) ->Message(FadedOut);
SendMessage(DestroyMonster, , MonsterTracker) @ Message(FadedOut) ->Message(MonsterDestroyed);
Fade(in) @ Message(MonsterDestroyed) ->Message(FadedIn);
SendMessage(StartTime, , Game Manager) @ Message(FadedIn);
This is mainly to get around issues that would arise from destroying the NPC during the conversation. The problem I'm having is that the 'Pause Game during conversation' unpausing at the end of the conversation, overwrites the pause being triggered by the sequencer command. I'd like to use the tick box if possible since it's a simple standard to keep across the project. But I'm not sure how to write the sequencer to keep the game paused from the conversation to the sequence with no issue.
Thanks a bunch in advance,
Rob
Awkward Pause Game Situation
Re: Awkward Pause Game Situation
Hi Rob,
Have you run into any issues when destroying the NPC during the conversation? It should work, with these exceptions:
1. Any sequencer commands that reference the NPC won't work after you destroy it (e.g., camera closeup on NPC).
2. If the NPC is the dialogue entry node's speaker or listener, the 'speaker' or 'listener' sequencer keywords will no longer be valid. If you've instantiated/activated a new replacement GameObject for the NPC, you can reference it by name (e.g., Camera(Closeup,NewNPC) instead of Camera(Closeup,speaker).)
Have you run into any issues when destroying the NPC during the conversation? It should work, with these exceptions:
1. Any sequencer commands that reference the NPC won't work after you destroy it (e.g., camera closeup on NPC).
2. If the NPC is the dialogue entry node's speaker or listener, the 'speaker' or 'listener' sequencer keywords will no longer be valid. If you've instantiated/activated a new replacement GameObject for the NPC, you can reference it by name (e.g., Camera(Closeup,NewNPC) instead of Camera(Closeup,speaker).)
Re: Awkward Pause Game Situation
Hi Tony,
I did have a script before that destroyed the monster during the conversation, but I need half the sequence to occur before it's destroyed and half after. So when it's destroyed the fade disappears in an instant and the game remains paused. It makes sense since it was cut short, but it means I need to sequence this somewhere else or via a different method.
This wouldn't be so much of an issue of the conversation always ended in this result. Since then I could just pause/unpause the game through code. But with multiple end results using the tick box would save a lot of hassle.
I could try destroying it during the conversation then triggering an onUse event to begin the second half of the sequence. I think that would result in the fade effect flickering since when the monsters destroyed so is the fade. The whole sequence feels a lot less janky right now with the sequenced part occurring outside the conversation. Just need to stop the rest of the game running.
I did have a script before that destroyed the monster during the conversation, but I need half the sequence to occur before it's destroyed and half after. So when it's destroyed the fade disappears in an instant and the game remains paused. It makes sense since it was cut short, but it means I need to sequence this somewhere else or via a different method.
This wouldn't be so much of an issue of the conversation always ended in this result. Since then I could just pause/unpause the game through code. But with multiple end results using the tick box would save a lot of hassle.
I could try destroying it during the conversation then triggering an onUse event to begin the second half of the sequence. I think that would result in the fade effect flickering since when the monsters destroyed so is the fade. The whole sequence feels a lot less janky right now with the sequenced part occurring outside the conversation. Just need to stop the rest of the game running.
Re: Awkward Pause Game Situation
Why does destroying the monster stop the fade? Shouldn't they be unrelated?
BTW, you could simplify the sequence a bit:
Or, if you play the sequence in a dialogue entry node's Sequence field without ending the conversation:
Is the monster the same as the NPC? Does it have the Dialogue System Trigger that's triggering the conversation?
BTW, you could simplify the sequence a bit:
Code: Select all
SendMessage(StopTime, , Game Manager);
Fade(out)->Message(FadedOut);
SendMessage(DestroyMonster, , MonsterTracker)@Message(FadedOut);
Fade(in)@Message(FadedOut)->Message(FadedIn);
SendMessage(StartTime, , Game Manager)@Message(FadedIn);
Code: Select all
Fade(out)->Message(FadedOut);
SendMessage(DestroyMonster, , MonsterTracker)@Message(FadedOut);
Fade(in)@Message(FadedOut)->Message(FadedIn)
Re: Awkward Pause Game Situation
Hi Tony,
Yeah the Monster is the same as the NPC. They can be killed or befriended but I was trying to keep it simple for the question. I'll just use 'Monster' from now on so it's easier to read the code. Because it is the same character I can't add the destroy Monster sequence message to the conversation itself because the Dialogue Manager prevents the Actor from being destroyed, which is fair enough to avoid bugs.
I don't know why the fade disappeared when the Monster was deleted. I assumed it would just stay black when the sequence was interrupted, but it seems like the fade is just removed when that happens. Regardless I have controls being disabled during conversations etc that make deleting him while still talking a problem in other ways to. I don't think it triggers the endConversation method in this way so it could cause more problems down the line.
The simplified sequence you provided seems to result in the fade out cutting off btw, rather than smoothly fading out. The extra message on the Monster Destroyed before Fading back in does more work than I thought . It's just the pause game part of this that's the real issue right now. I am pretty happy with the fade and how simple the sequencer code is, it's a nice powerful feature. Looking forward to coding cutscenes etc with it later down the line.
Cheers for looking into this for me,
Rob
Yeah the Monster is the same as the NPC. They can be killed or befriended but I was trying to keep it simple for the question. I'll just use 'Monster' from now on so it's easier to read the code. Because it is the same character I can't add the destroy Monster sequence message to the conversation itself because the Dialogue Manager prevents the Actor from being destroyed, which is fair enough to avoid bugs.
I don't know why the fade disappeared when the Monster was deleted. I assumed it would just stay black when the sequence was interrupted, but it seems like the fade is just removed when that happens. Regardless I have controls being disabled during conversations etc that make deleting him while still talking a problem in other ways to. I don't think it triggers the endConversation method in this way so it could cause more problems down the line.
The simplified sequence you provided seems to result in the fade out cutting off btw, rather than smoothly fading out. The extra message on the Monster Destroyed before Fading back in does more work than I thought . It's just the pause game part of this that's the real issue right now. I am pretty happy with the fade and how simple the sequencer code is, it's a nice powerful feature. Looking forward to coding cutscenes etc with it later down the line.
Cheers for looking into this for me,
Rob
Re: Awkward Pause Game Situation
Hi Rob,
What if you change that first line to:
This should guarantee that it calls the Game Manager's StopTime() method after the previous Dialogue System Trigger has ended the conversation and unpaused time.
What if you change that first line to:
Code: Select all
SendMessage(StopTime, , Game Manager)@0.1
Re: Awkward Pause Game Situation
That did it. There was a visible 1 frame of the game running with 0.1 so I reduced the time further so it's not even noticeable now.
Cheers for the help,
Rob
Cheers for the help,
Rob
Re: Awkward Pause Game Situation
Glad that's working. If you ever want to pare it down to the bare minimum of time, you could write a custom sequencer command instead of using SendMessage(). Something like (roughly):
Then replace SendMessage(StopTime,,GameManager)@0.1 with StopTime().
Code: Select all
public class SequencerCommandStopTime : SequencerCommand
{
IEnumerator Start()
{
yield return new WaitForEndOfFrame();
FindObjectOfType<GameManager>().StopTime();
}
}