2D VN scene change set up

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
RS_EG
Posts: 7
Joined: Tue Feb 22, 2022 6:16 pm

2D VN scene change set up

Post by RS_EG »

Hello!

Have been learning to use the Dialogue System to create a 2D visual novel. During gameplay the intention is to be able to load back & forth between 2 scenes which have different sets of art in each scene (chars, backgrounds, vfx etc). The reason for changing scenes instead of having everything & disabling/enabling per convo in just the 1 scene was hopefully this way would be less impactful on performance

The set up I have so far is:
- Scene 1 contains the Dialogue Manager, which holds the Main Canvas with all the game character Dialogue Panels nested. The Main Camera is located here too & referenced on the Main Canvas, set to Screen Space - Camera
It also has a separate scene canvas which holds all the background & character images for this 1st scene.
The last node in Scene 1's dialogue loads into Scene 2, carrying over the Dialogue Manager
- Scene 2 is set up in the same manner currently with its own scene canvas holding the art to be used only within this scene, as well as a separate conversation to play on start. The Dialogue Manager & Camera in this scene is only used to be able to hit Play when testing this scene, which I would disable when playing from the beginning from my understanding

I'm having trouble when attempting to load to Scene 2 correctly after dialogue ends in Scene 1. What happens right now is it loads to Scene 2 but doesn't start the conversation immediately, & because I have a scene canvas (set to Screen Space - Camera) the art is broken in the hierarchy too as I'm not sure how to reference the Main Camera carried over from Scene 1

I'm wondering if it's possible to have this set up functional? Or maybe if there's a better recommended way to set this up?

Thanks in advance :)
User avatar
Tony Li
Posts: 22142
Joined: Thu Jul 18, 2013 1:27 pm

Re: 2D VN scene change set up

Post by Tony Li »

Hi,

Is there a specific reason to set the the scene canvases to Screen Space - Camera? Typically that's only necessary for VR, AR, or certain camera effects that you might want to apply to the canvas.

If possible, it'll be easier to set the scene canvases to Screen Space - Overlay so you don't need to worry about the camera.

If it must be set to Screen Space - Camera, you'll need to add a little script that assigns the camera to the new scene's canvas. Something like:

AssignMainCameraToCanvas.cs

Code: Select all

using UnityEngine;
[RequireComponent(typeof(Canvas>))]
public class AssignMainCameraToCanvas : MonoBehaviour
{
    void Start() { GetComponent<Canvas>().worldCamera = Camera.main;
}
Scene 2's conversation probably isn't starting because scene 1's conversation is still active.

To get scene 2 to start its conversation, make sure scene 1's conversation is configured to end when it changes scenes.

I'll assume you're using a Dialogue System Trigger in scene 2 to start scene 2's conversation. If so, set that Dialogue System Trigger to OnSaveDataApplied. It will start the conversation after applying save data from scene 1 or, if you're playing directly in scene 2, after however many frames are specified by the Save System component's Frames To Wait Before Apply Data field.
RS_EG
Posts: 7
Joined: Tue Feb 22, 2022 6:16 pm

Re: 2D VN scene change set up

Post by RS_EG »

Hello,

Have always set up 2D games to have Screen Space - Camera as I found it easier to visualise gameplay, but changed to Screen Space - Overlay as suggested & that solves the camera issue when changing scenes, thanks!
Scene 2's conversation probably isn't starting because scene 1's conversation is still active.
Ahhh ok that makes sense, I see it now
As a follow up question - how do I change scenes after a conversation has ended? I have been using LoadLevel() on the last node but if I'm understanding correctly that will load to the next scene whilst retaining the conversation as still active?
User avatar
Tony Li
Posts: 22142
Joined: Thu Jul 18, 2013 1:27 pm

Re: 2D VN scene change set up

Post by Tony Li »

Hi,

If you're waiting for continue button clicks, you can still use LoadLevel() on the last node with a sequence like this:

Code: Select all

required LoadLevel(next-scene);
Continue()
The first command loads the next scene. The second command simulates a continue button click to end the conversation. The 'required' keyword in the first command guarantees that the LoadLevel() command runs even if the Continue() command happens to run first.

Alternatively, you can add another Dialogue System Trigger to one of the conversation participants and set its trigger to OnConversationEnd. Then select Add Action > Play Sequence, and use the LoadLevel() sequencer command in the Sequence field.
RS_EG
Posts: 7
Joined: Tue Feb 22, 2022 6:16 pm

Re: 2D VN scene change set up

Post by RS_EG »

Hello,

Thanks for the recommendations, all seems to be functioning on my side now, thanks!

One weird thing though that is now happening that I can't figure out is in Scene 2 (a conversation between 2 actors), one of the nodes causes the continue button (invisible button covering the whole screen) to disable itself
So as you're playing you're unable to click the screen to advance the dialogue after getting to a certain node. None of the nodes in this 2nd conversation have any sequences so I'm a bit stumped as to why this is occurring
User avatar
Tony Li
Posts: 22142
Joined: Thu Jul 18, 2013 1:27 pm

Re: 2D VN scene change set up

Post by Tony Li »

Hi,

If the nodes don't have sequences, I have no idea. Would it be possible for you to send a reproduction project to tony (at) pixelcrushers.com?
RS_EG
Posts: 7
Joined: Tue Feb 22, 2022 6:16 pm

Re: 2D VN scene change set up

Post by RS_EG »

Hello,

Have zipped & emailed your way. Thanks again in advance :)
User avatar
Tony Li
Posts: 22142
Joined: Thu Jul 18, 2013 1:27 pm

Re: 2D VN scene change set up

Post by Tony Li »

Hi,

Thanks for putting together the reproduction project. I replied to your email. In your V1 Dialogue UI, the Continue Button isn't assigned to Maya Subtitle Panel. It should work if you assign it.
Post Reply