LoadLevel and Sequences
LoadLevel and Sequences
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!
Thanks!!
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!
Thanks!!
Re: LoadLevel and Sequences
Hi,
In the sequence above:
When the sequence plays, "{{end}}" will be replaced by "3".
If your sequence is this:
then at runtime it will be:
which isn't a valid sequencer command.
However, if your sequence is this:
then at runtime it will be:
which is a valid command that will delay for 3 seconds.
You can also use {{end}} with the "@" command, like this:
At runtime, it will be:
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
- 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.
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".
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.
{{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}}
Code: Select all
3
However, if your sequence is this:
Code: Select all
Delay({{end}})
Code: Select all
Delay(3)
You can also use {{end}} with the "@" command, like this:
Code: Select all
LoadLevel(nextLevel)@{{end}}
Code: Select all
LoadLevel(nextLevel)@3
Re: LoadLevel and Sequences
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.
Not sure if all those timers would make the clean transition. (I cannot test it right now )
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;
Re: LoadLevel and Sequences
Hi,
I don't think you need @9999. Here's an example: LoadLevelExample_DS1_2018-06-08.unitypackage
It uses this Sequence:
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.
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;
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
Thanks Tony! I'll give a try and I'll post go did it go.
-
- Posts: 22
- Joined: Fri Oct 01, 2021 11:50 am
Re: LoadLevel and Sequences
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!
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
Hi,
Add an extra dialogue entry node after "Hold on tight...".
Leave the extra node's Dialogue Text blank. Set the Sequence to:
Here's a version with comments that indicate what each line does:
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.
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
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.
-
- Posts: 22
- Joined: Fri Oct 01, 2021 11:50 am
Re: LoadLevel and Sequences
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!
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
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.
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.
-
- Posts: 22
- Joined: Fri Oct 01, 2021 11:50 am
Re: LoadLevel and Sequences
Thank you Tony.