Page 1 of 2

LoadLevel and Sequences

Posted: Thu Jun 07, 2018 4:08 pm
by Alatriste
Hi,

A few questions about LoadLevel and the best way to do it, among some questions regarding the Sequences.
I'm trying to control as much as possible through the Dialogue System sequences, so after a dialogue, I want to load another scene and deactivate the NPC portrait image game object.

What I did works partially but it doesn't look "clean". Here are my main questions:

1) I know that the sequence runs everything at the same time unless pauses are added, but how I can control the sequence commands so everything happens once the skip dialogue button has been pressed?

2) Because I'm not sure how to do it, I'm adding extra dialogue nodes at the end of a dialogue so the sequence commands run when I'm sure the dialogue has been displayed. ("Dialogue Node" -> "Empty Dialogue node with sequence script") but I don't think that's the right way to do it.

3) After a few dialogue nodes, I want to load another scene. I use the LoadLevel but again, I'm not sure where I should place the script: should it be in the last dialogue node or in an empty one?

4) Then, after loading the next scene, I have a SetActive(gameObject, false)@1. However, the gameObject is not disabled.

5) Is it possible to use the SetActive command to enable gameObjects by tag?

6)And finally, what's the difference between "Delay({{end}})" and "{{end}}". When should I be using one or another one?

Because of the speed of the commands, sometimes weird things happen. (gameObjects do not disable, dialogues UI panels showing anything...)

Lots of questions! :D

Thanks!!

Re: LoadLevel and Sequences

Posted: Thu Jun 07, 2018 10:48 pm
by Tony Li
Hi,
Alatriste wrote: Thu Jun 07, 2018 4:08 pm1) I know that the sequence runs everything at the same time unless pauses are added, but how I can control the sequence commands so everything happens once the skip dialogue button has been pressed?
Use the "required" keyword, and set the command's time to something equivalent to infinity such as 9999:

Code: Select all

Camera(Closeup);
required Camera(Wide,listener)@9999
In the sequence above:
  • Camera(Closeup) runs immediately.
  • Camera(Wide,listener) only runs when the continue button is clicked. Technically it runs after 9999 seconds, but the required keyword means it's guaranteed to run if the player clicks the continue button before 9999 seconds.
I think if you use "required" you won't have to do (2) and (3) that you mentioned above.
Alatriste wrote: Thu Jun 07, 2018 4:08 pm4) Then, after loading the next scene, I have a SetActive(gameObject, false)@1. However, the gameObject is not disabled.
Check the Console window. Are there any warnings that it can't find the GameObject? Maybe there's a typo in the name such as "gameObject" instead of "GameObject".
Alatriste wrote: Thu Jun 07, 2018 4:08 pm5) Is it possible to use the SetActive command to enable gameObjects by tag?
No, but you could write your own sequencer command to do this. There's a starter template in the Scripts/Templates folder. I'll also add this to the roadmap for 2.x since it's a good idea.
Alatriste wrote: Thu Jun 07, 2018 4:08 pm6)And finally, what's the difference between "Delay({{end}})" and "{{end}}". When should I be using one or another one?
{{end}} is a keyword for a number value based on the length of the subtitle text. Let's say the subtitle text is 90 characters long. And the Dialogue Manager's Subtitle Settings > Subtitle Chars Per Second is 30. Then {{end}} will be 90 / 30, which is 3 seconds.

When the sequence plays, "{{end}}" will be replaced by "3".

If your sequence is this:

Code: Select all

{{end}}
then at runtime it will be:

Code: Select all

3
which isn't a valid sequencer command.

However, if your sequence is this:

Code: Select all

Delay({{end}})
then at runtime it will be:

Code: Select all

Delay(3)
which is a valid command that will delay for 3 seconds.

You can also use {{end}} with the "@" command, like this:

Code: Select all

LoadLevel(nextLevel)@{{end}}
At runtime, it will be:

Code: Select all

LoadLevel(nextLevel)@3

Re: LoadLevel and Sequences

Posted: Fri Jun 08, 2018 3:40 am
by Alatriste
Thanks Tony for the clarification.

One more questions about the LoadLevel. Let say I want to use the command in the middle of a conversation, just right after a dialogue node has finished. (so the dialogue continues after loading, but the scene changes.) The flow is as follow:

1. Wait for the player to press the skip button.
2. Fade Out 2 seconds
3. Load Level
4. Activate gameObject. (this is tricky for me to understand, as the new scene has to be already loaded so the object can be enabled)
5. Fade In
6. Finish the sequence and continue to the next dialogue node.

Code: Select all

Fade(out, 2)@9999;
LoadLevel(New Level)@9999;
SetActive(gameObject, true)@9999;
Fade(in,2)@9999;
Not sure if all those timers would make the clean transition. (I cannot test it right now :P)

Re: LoadLevel and Sequences

Posted: Fri Jun 08, 2018 10:13 am
by Tony Li
Hi,

I don't think you need @9999. Here's an example: LoadLevelExample_DS1_2018-06-08.unitypackage

It uses this Sequence:

Code: Select all

Fade(stay, 2);
required LoadLevel(New Level)@2;
required SetActive(gameObject, true)@4;
required Fade(in,2)@4;
First it fades to black over 2 seconds and stays faded out (the "stay" part).

Then it loads the new level at 2-seconds.

At 4-seconds, it activates gameObject. This should give LoadLevel enough time to load the new level first. Also note: If gameObject starts inactive, it must be a child of an active GameObject.

Another way to activate the gameObject would be to add a Sequence Trigger or Persistent Active Data component to New Level. Set the Sequence Trigger to OnStart.

Finally, at 4-seconds it fades in.

Re: LoadLevel and Sequences

Posted: Fri Jun 08, 2018 11:17 am
by Alatriste
Thanks Tony! I'll give a try and I'll post go did it go.

Re: LoadLevel and Sequences

Posted: Fri Feb 11, 2022 4:43 pm
by fallingstarint
Hello,

I am bumping this post because I have a related question and I don't quite understand how to solve it even if I am not too far... I hope it is ok!

My conversation ends on the NPC saying: "Hold on tight, cause you’re in for quite a journey!"

I would like that when the player clicks on the "continue" button, it:
- closes the conversation
- fades the screen out to white
- loads the scene "Opener" (already added to the build settings)

Then the player can just play in the "Opener" scene.

Could you please tell me what Sequence to write for it to do this?

Thank you in advance!

Re: LoadLevel and Sequences

Posted: Fri Feb 11, 2022 5:25 pm
by Tony Li
Hi,

Add an extra dialogue entry node after "Hold on tight...".

Leave the extra node's Dialogue Text blank. Set the Sequence to:

Code: Select all

SetContinueMode(false);
SetDialoguePanel(false);
Fade(out, 1, #ffffff);
required LoadLevel(Opener)@1;
required SetContinueMode(true)@1;
Continue()@1
Here's a version with comments that indicate what each line does:

Code: Select all

SetContinueMode(false);  // Turn off continue button mode.
SetDialoguePanel(false);  // Hide the dialogue UI.
Fade(out, 1, #ffffff);  // Fade to white over 1 second.
required LoadLevel(Opener)@1;  // Load "Opener" at the 1-second mark.
required SetContinueMode(true)@1;  // Restore continue button mode at the 1-second mark.
Continue()@1;  // Continue to end the conversation at the 1-second mark.
Fade(out) might suffice for what you want. However, instead of Fade(out), I recommend setting up the save system with a scene transition manager that fades out to white when leaving a scene and fades back in when entering a new scene. Examine the Demo's Dialogue Manager Prefab for an example. It's configured to fade to black and back in.

Re: LoadLevel and Sequences

Posted: Sat Feb 12, 2022 2:41 am
by fallingstarint
Thank you SO MUCH Tony, this is perfect!

Almost perfect, ahaha, is there a way to fade out the audio from the first scene as well during the fade to white?

I didn't use the save manager with its scene transitioner for this particular scene because it is a special scene that won't work like the other in game, that's why I needed that!

Re: LoadLevel and Sequences

Posted: Sat Feb 12, 2022 9:09 am
by Tony Li
Hi,

You'll have to write a custom sequencer command (they're not difficult if you're a little comfortable with scripting) or handle it some other way.

Re: LoadLevel and Sequences

Posted: Sat Feb 12, 2022 9:27 am
by fallingstarint
Thank you Tony.