Dialogue System Events works for all

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Fitbie
Posts: 44
Joined: Tue Dec 07, 2021 6:30 pm

Dialogue System Events works for all

Post by Fitbie »

Hi Tony and everyone. I have a question: I use Dialogue System Events ("On conversation line", "on bark line", etc.) to call the animator component and set the trigger. But here's the problem: for example "on conversation line" works for all gameobjects in the scene. One gameobject speaks, but animation is called for all (because of the "on conversation line") . Can this be fixed? Thank you!
User avatar
Tony Li
Posts: 21981
Joined: Thu Jul 18, 2013 1:27 pm

Re: Dialogue System Events works for all

Post by Tony Li »

Hi,

OnConversationLine is called on the speaker and listener, and on the Dialogue Manager.

If you need to distinguish and do something only on the speaker, you could hook up a method like this:

Code: Select all

void HandleLine(Subtitle subtitle)
{
    if (subtitle.speakerInfo.transform == this.transform)
    {
        // call the animator component and set the trigger
    }
}
If you do this, hook up the OnConversationEnd event to the Dynamic method.

Alternatively, you can skip the Dialogue System Events component altogether and add a script with an OnConversationLine method instead:

Code: Select all

void OnConversationLine(Subtitle subtitle)
{
    if (subtitle.speakerInfo.transform == this.transform)
    {
        // call the animator component and set the trigger
    }
}
Fitbie
Posts: 44
Joined: Tue Dec 07, 2021 6:30 pm

Re: Dialogue System Events works for all

Post by Fitbie »

Thank you, now the bark animation works properly. But I have another question: I want the player gameobject to play the conversation animation only when I press the response button. I understand that the animation can be connected to play when NPC subtitles, but sometimes this doesn't work correctly. Can this be done in Dialogue events or should it be done in Dialogue UI response button template? (response menu response and timeout events don't work the way I want, I need the animation to be called specifically by pressing response button)
User avatar
Tony Li
Posts: 21981
Joined: Thu Jul 18, 2013 1:27 pm

Re: Dialogue System Events works for all

Post by Tony Li »

Hi,

Can you add a sequencer command to the player response nodes' Sequence fields? If it applies to all player response nodes, you can set the Dialogue Manager's Camera & Cutscene Settings > Default Player Sequence. This is the usual way to kick off UX activity such as animations.

Alternatively, you can use an OnConversationLine method and check if the speaker is the player:

Code: Select all

void OnConversationLine(Subtitle subtitle)
{
    if (subtitle.speakerInfo.IsPlayer && subtitiel.speakerInfo.transform == this.transform)
    {
        // I'm the player and I'm speaking this line, so do my animation.
    }
}
Or you can hook up an event to the response buttons' OnClick() event. If you do this, make sure to also connect the OnClick() event to StandardUIResponseButton.OnClick.
Fitbie
Posts: 44
Joined: Tue Dec 07, 2021 6:30 pm

Re: Dialogue System Events works for all

Post by Fitbie »

Thank you so much, I figured it out.
Can I ask one more question, it's not on this topic?
I use SaveSystem.LoadSceneAtSpawnpoint to transition between levels.But the problem: when loading a level, I see a player "teleporting". I figured out that this is because save system moves the player to the spawnpoint after the transition animation (screen fade) plays. I tried changing the duration in transition manager but it didn't help. And in some scenes everything is working fine, and I can not see how the player is "teleported" to the spawnpoint. I really hate to interrupt you, but I've been trying to fix this for the 16th hour. What could this be related to?
User avatar
Tony Li
Posts: 21981
Joined: Thu Jul 18, 2013 1:27 pm

Re: Dialogue System Events works for all

Post by Tony Li »

Hi,

Try setting the Save System component's Frames To Wait Before Apply Data to zero. If that causes problems, set it to 1. This value lets you specify how many frames to give other, non-Dialogue System components to initialize themselves before the Save System updates them.

Then use a SceneFaderCanvas to animate fade-to-black and fade-from-black animations like in DemoScene1 if you're not already using it. You can adjust the animation to stay dark longer in order to give the scene more time to teleport the player.

If that doesn't help, examine your player control and camera control scripts. They may be holding onto the old position and gradually translating the player or camera to the new position, when instead they should snap to the new position.
Fitbie
Posts: 44
Joined: Tue Dec 07, 2021 6:30 pm

Re: Dialogue System Events works for all

Post by Fitbie »

Tell me please, does your "screen fade animation" have a fixed animation time? Or is the "Hide" trigger sent only when the scene has loaded finally? If the player has a bad computer, won't he see such "teleportations" ahead of time?
User avatar
Tony Li
Posts: 21981
Joined: Thu Jul 18, 2013 1:27 pm

Re: Dialogue System Events works for all

Post by Tony Li »

Hi,

If the Save System has a Standard Scene Transition Manager component, it uses this process to change scenes:
  • Run the Standard Scene Transition Manager's Leave Scene actions (e.g., fade to black), and wait until they're done.
  • Load the next scene asynchronously, and wait until it's fully loaded.
  • Run the Standard Scene Transition Manager's Enter Scene actions (e.g., fade from black).
  • While the Enter Scene actions are running, wait the number of frames specified by the Save System's Frames To Wait Before Apply Data. After that many frames, apply the save data (e.g., move player using Position Saver).
The fade to black and fade from black animations are fixed time, but you can see above that they wait until the correct time to run.
Post Reply