How can I load another scene or open another panel when the line ends?

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
ironmanman
Posts: 16
Joined: Tue Apr 04, 2017 10:10 am

How can I load another scene or open another panel when the line ends?

Post by ironmanman »

Dear Tony,

The current default situtiaon is that ,when the player or npc's line come to an END,the whole dialogue panel disappears.

But I am figuring how to load another scene or open another panel when the line ends?

just like

-Start scene
-"Npc:hello,world"-"Player:Goodbye![END]"
-Load scene 2 or open a panel,it shows [Gave Over!]

Where can I modify the setting?

Thank you!: )
User avatar
Tony Li
Posts: 21722
Joined: Thu Jul 18, 2013 1:27 pm

Re: How can I load another scene or open another panel when the line ends?

Post by Tony Li »

Hi,

I'll provide a few ways to do this so you can choose the one that works best for your needs.

To change scenes during a conversation, use the LoadLevel() sequencer command:
  • Dialogue Text: [Player] "Take me to the cave."
  • Sequence: LoadLevel(Cave)
Or, to change scenes at the end of a conversation, add a Start Sequence On Dialogue Event component to one of the GameObjects that receives the OnConversationEnd event (the player, the NPC, or the Dialogue Manager). Set the component's Trigger to OnConversation. Add an element to the OnEnd list, and use the same LoadLevel() sequencer command as above. You can set a condition so it only changes to the level if certain conditions are true, such as if you've set a Dialogue System variable to a specific value.


Or, add a Dialogue System Events component to one of the GameObjects that receives the OnConversationEnd event. This adds events that you can connect in the Unity inspector in the same way that you can connect event handlers to a UI Button's OnClick() event.


Or, write a script that has an OnConversationEnd() method, and add it to one of the GameObjects that receives the OnConversationEnd event. In this method, change the scene however you want.
ironmanman
Posts: 16
Joined: Tue Apr 04, 2017 10:10 am

Re: How can I load another scene or open another panel when the line ends?

Post by ironmanman »

Hi!Tony,

Thank you!! It works!

But here comes another question.

I have 2 scenes: LevelStart and LevelEnd.

The game starts from LevelStart . When the line ends, it switches to LevelEnd. When I click Play button on Unity3d Panel, the conversation starts right away. The conversation ends up to the LevelEnd.

In the LevelEnd scene, there is a button. Onclick() ,it connects an empty object with the script Game Saver.
So when i click the button--->GameSaver-->GameSaver.RestartGame.

It did load the LevelStart,but nothing happen. The conversation doesn't start again just like I click Play button at the first beginning.

The question is as short as How to restart the game .: )

Thank you for your patience. : )
User avatar
Tony Li
Posts: 21722
Joined: Thu Jul 18, 2013 1:27 pm

Re: How can I load another scene or open another panel when the line ends?

Post by Tony Li »

Hi,

I have two recommendations:

1. In LevelStart, get rid of the Play button. Instead, change the Conversation Trigger to OnStart. This way, when GameSaver loads LevelStart, the conversation will automatically restart.

2. Or, add a new scene 0 named GameStart. Put the Play button in GameStart. When the player clicks the Play button, load LevelStart. Set up LevelStart as #1 above. This way the player will see a Play button when the game first loads, but when the game restarts it will go directly to the conversation. If you're using a Level Manager component, set its Default Starting Level to LevelStart. Otherwise, set the Game Saver's Starting Level to LevelStart.
ironmanman
Posts: 16
Joined: Tue Apr 04, 2017 10:10 am

Re: How can I load another scene or open another panel when the line ends?

Post by ironmanman »

Tony Li wrote:Hi,

I have two recommendations:

1. In LevelStart, get rid of the Play button. Instead, change the Conversation Trigger to OnStart. This way, when GameSaver loads LevelStart, the conversation will automatically restart.

2. Or, add a new scene 0 named GameStart. Put the Play button in GameStart. When the player clicks the Play button, load LevelStart. Set up LevelStart as #1 above. This way the player will see a Play button when the game first loads, but when the game restarts it will go directly to the conversation. If you're using a Level Manager component, set its Default Starting Level to LevelStart. Otherwise, set the Game Saver's Starting Level to LevelStart.
Hi Tony,

I made a simple demo. It restarted and loaded to LevelStart Again.But the conversation do not start,I don't know why.

In the LevelStart, I attached the Conversation Trigger to Dialogue Manager and set the Conversation Trigger to OnStart.
In the LevelEnd,I created a empty object and attach the Game Saver to it . And I made a button linked to the Restart function.

When I clicked the button. The scene switched from LevelEnd to LevelStart. But nothing shows on the screen. The conversation did not start.

I used Level Manager component instead of Game Saver component. I even write the script call the function SceneManager.LoadLevel("LevelStart"); But it resulted to the same. When I clicked the button, the scene switched to LevelStart, the conversation didn't start.

Please Help~~~~
Attachments
屏幕快照 2017-04-14 15.07.31.png
屏幕快照 2017-04-14 15.07.31.png (78.56 KiB) Viewed 2777 times
屏幕快照 2017-04-14 15.04.33.png
屏幕快照 2017-04-14 15.04.33.png (112.2 KiB) Viewed 2777 times
屏幕快照 2017-04-14 15.03.19.png
屏幕快照 2017-04-14 15.03.19.png (35.61 KiB) Viewed 2777 times
User avatar
Tony Li
Posts: 21722
Joined: Thu Jul 18, 2013 1:27 pm

Re: How can I load another scene or open another panel when the line ends?

Post by Tony Li »

Move the Conversation Trigger to a separate GameObject in LevelStart.

The Dialogue Manager GameObject survives across scene changes. This means it only runs "OnStart" once, at the very beginning of the game.

If you move the Conversation Trigger to a different GameObject in LevelStart, it will run "OnStart" every time you load LevelStart.
Post Reply