Scene Event works only once

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
User avatar
DryreL
Posts: 29
Joined: Sat Dec 26, 2020 1:58 pm

Scene Event works only once

Post by DryreL »

Hello,

I was trying to change the animation while character in conversation. (Idle -> Talk)

My character has two state, idle (base layer) and talk (overlap layer). New State is empty state. I set a transition "New State -> Talk" to "Talk" trigger.
image_2021-09-18_000440.png
image_2021-09-18_000440.png (22.48 KiB) Viewed 3838 times

Then, I added "SetTrigger" event to dialogue's Scene Event. This first dialogue runs the command, that's ok.

image_2021-09-18_000838.png
image_2021-09-18_000838.png (20.17 KiB) Viewed 3838 times

But in the next dialogue state, I want to Character A return Idle animation while Character B is starting to Talk animation.

image_2021-09-18_001054.png
image_2021-09-18_001054.png (18.43 KiB) Viewed 3838 times

I added Scene Event again, but it doesn't work in the game. Is it one time-only event?

If it is, how should I change the animations while they are in conversation?

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

Re: Scene Event works only once

Post by Tony Li »

Hi,

Scene events execute every time the node is used in a conversation, not just once.

However, for animator control, I recommend using the AnimatorTrigger() sequencer command instead of scene events. If you're using triggers, you'll also want to use another trigger to return to Idle. Resetting the Talk trigger won't return the animator to Idle. Example Sequence field value:

Code: Select all

AnimatorTrigger(Talk);
required AnimatorTrigger(Idle)@Message(Typed)
The first line in the Sequence sets the Talk trigger on the speaker.

The second line waits until the typewriter effect has finished. Then it sets a trigger named Idle.
User avatar
DryreL
Posts: 29
Joined: Sat Dec 26, 2020 1:58 pm

Re: Scene Event works only once

Post by DryreL »

Hi, thanks your the help. I added your code to Sequencer and deleted scene events but there's a little problem.

Sequencer does not work as intended. Character A plays talk animation in the beginning and never stops even the conversation order goes to Characer B.
User avatar
Tony Li
Posts: 22108
Joined: Thu Jul 18, 2013 1:27 pm

Re: Scene Event works only once

Post by Tony Li »

Are there any errors or warnings in the Console window?

In my previous reply, notice the second line in the Sequence. It's an example of how to change the speaker's animator back to the "Idle" animation. Your actual command may be different, depending on how you've set up your animator controller.
User avatar
Tony Li
Posts: 22108
Joined: Thu Jul 18, 2013 1:27 pm

Re: Scene Event works only once

Post by Tony Li »

Another note:

If you're not using the typewriter effect, you can modify the sequence. Example:

Code: Select all

AnimatorTrigger(Idle, listener);
AnimatorTrigger(Talk, speaker);
{{default}}
I included the {{default}} keyword to tell the sequence to include the Dialogue Manager's Default Sequence.
User avatar
DryreL
Posts: 29
Joined: Sat Dec 26, 2020 1:58 pm

Re: Scene Event works only once

Post by DryreL »

Hi,

There was an error "Animator not found" at start, then I drag character game objects to Dialogue System Trigger's Conversation Actor and Conversant, the error has gone. There is no error right now.

Here's the animator setup:
image_2021-09-19_185854.png
image_2021-09-19_185854.png (12.32 KiB) Viewed 3813 times
Trigger names are same as in your code.

I tested triggers manually while game is running on editor, they works fine.

I don't understand why triggers don't work on conversation.
User avatar
DryreL
Posts: 29
Joined: Sat Dec 26, 2020 1:58 pm

Re: Scene Event works only once

Post by DryreL »

Tony Li wrote: Sun Sep 19, 2021 11:48 am Another note:

If you're not using the typewriter effect, you can modify the sequence. Example:

Code: Select all

AnimatorTrigger(Idle, listener);
AnimatorTrigger(Talk, speaker);
{{default}}
I included the {{default}} keyword to tell the sequence to include the Dialogue Manager's Default Sequence.
I'm using typewriter effect but I give it a try.

I pasted same code to Character A.
And this code to Character B:

Code: Select all

AnimatorTrigger(Talk, listener);
AnimatorTrigger(Idle, speaker);
{{default}}
Simply changed the places of Talk and Idle.

Result:
Character A is playing Talk animation (never stops), Character B does nothing
User avatar
Tony Li
Posts: 22108
Joined: Thu Jul 18, 2013 1:27 pm

Re: Scene Event works only once

Post by Tony Li »

The speaker should always talk. The listener should always stop talking. Use this in all sequences:

Code: Select all

AnimatorTrigger(Idle, listener);
AnimatorTrigger(Talk, speaker);
(One way to use it in all sequences is to add it to the Dialogue Manager's Default Sequence, and leave the nodes' Sequence fields blank.)

The speaker is the dialogue entry node's Actor, which is not necessarily the conversation's Actor. The conversation's Actor stays the same throughout the conversation, but the dialogue entry node's Actor may change with each node.

Also, please see: Character GameObject Assignments.
User avatar
DryreL
Posts: 29
Joined: Sat Dec 26, 2020 1:58 pm

Re: Scene Event works only once

Post by DryreL »

Hi, I solved the problem, thank you!
Post Reply