Start conversation when new scene is loaded? (ink)

Announcements, support questions, and discussion for the Dialogue System.
Frost Mage
Posts: 9
Joined: Fri Dec 18, 2020 7:35 am

Start conversation when new scene is loaded? (ink)

Post by Frost Mage »

Hello,
Apologies if this is a RTFM question but I can't seem to find a straight forward answer and have tried multiple approaches. I simply want to set up each scene so that a conversation starts as soon as the scene loads. Is it possible to do this with dialogue triggers or will I need to create my own system with scripts? I am using inkle to generate my conversations.
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: Start conversation when new scene is loaded? (ink)

Post by Tony Li »

Hi,

Set the scene's Dialogue System Trigger to OnStart.
Frost Mage
Posts: 9
Joined: Fri Dec 18, 2020 7:35 am

Re: Start conversation when new scene is loaded? (ink)

Post by Frost Mage »

Hi Tony
I tried that. but it only seems to run when the game first starts, even if I include a dialogue manager in every scene. If I switch scenes while the game is running, the conversation does not start.
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: Start conversation when new scene is loaded? (ink)

Post by Tony Li »

Hi,

Are the Dialogue Manager's Other Settings > Allow Only One Instance and Don't Destroy On Load checkboxes ticked?

Are there any errors or warnings in the Console window?
Frost Mage
Posts: 9
Joined: Fri Dec 18, 2020 7:35 am

Re: Start conversation when new scene is loaded? (ink)

Post by Frost Mage »

Both settings are checked on the Dialogue Manager object. There are no errors in the console. I have also double checked that all json files are registered with the Dialogue Manager ink integration script. I don't know if this would make a difference, but I am changing the scene via LoadLevel() called in my ink script.
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: Start conversation when new scene is loaded? (ink)

Post by Tony Li »

Hi,
Frost Mage wrote: Sat Dec 26, 2020 9:04 pmI don't know if this would make a difference, but I am changing the scene via LoadLevel() called in my ink script.
That's probably it. Your Ink script runs within the context of a Dialogue System conversation. The conversation is still active when it calls LoadLevel(), so the Dialogue System won't let it start a new conversation.

One way to handle it is to set a Dialogue System variable to the name of the next scene:

1. Define a variable -- for example, named "NextScene" -- and set its initial value to "none".

2. In your Ink script, use {Sequence(SetVariable(NextScene,sceneName))} to set the NextScene variable.

3. Add a Dialogue System Trigger to the Dialogue Manager.
  • Set it to OnConversationEnd.
  • In the Conditions section, check if the variable NextScene is no longer "none".
  • In the Actions section, select Add Action > Play Sequence. In the Sequence, use LoadLevel() to load the scene and SetVariable() to set the variable back to "none".
When the conversation ends, this Dialogue System Trigger will see that you set the NextScene variable, and it will load the specified scene.

loadLevelOnConversationEnd.png
loadLevelOnConversationEnd.png (40.17 KiB) Viewed 1151 times
Frost Mage
Posts: 9
Joined: Fri Dec 18, 2020 7:35 am

Re: Start conversation when new scene is loaded? (ink)

Post by Frost Mage »

Thank you Tony, that worked like a charm!
Frost Mage
Posts: 9
Joined: Fri Dec 18, 2020 7:35 am

Re: Start conversation when new scene is loaded? (ink)

Post by Frost Mage »

Addendum:
I am trying to add saving to my project, but every time I add the Dialogue System saver component to my project the scene transitions break down. No errors are shown, and it appears that the new dialogue is run for a split second before closing.
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: Start conversation when new scene is loaded? (ink)

Post by Tony Li »

Hi,

What Saver components are you using? If you're using a Conversation State Saver component, remove it. Conversation State Saver isn't designed to work with the Ink integration.

Are there any warnings or errors in the Console window?
Frost Mage
Posts: 9
Joined: Fri Dec 18, 2020 7:35 am

Re: Start conversation when new scene is loaded? (ink)

Post by Frost Mage »

I removed the Dialogue save system component and everything seems to work fine. I am using a "JSON data serializer" and "Playerprefs Saved Game Data Storer" components. I have the "include in save data" option checked on my Ink integrator.
Post Reply