Page 1 of 1

Scene Event works only once

Posted: Fri Sep 17, 2021 5:15 pm
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 3839 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 3839 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 3839 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!

Re: Scene Event works only once

Posted: Fri Sep 17, 2021 9:22 pm
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.

Re: Scene Event works only once

Posted: Sun Sep 19, 2021 9:39 am
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.

Re: Scene Event works only once

Posted: Sun Sep 19, 2021 9:48 am
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.

Re: Scene Event works only once

Posted: Sun Sep 19, 2021 11:48 am
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.

Re: Scene Event works only once

Posted: Sun Sep 19, 2021 12:04 pm
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 3814 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.

Re: Scene Event works only once

Posted: Sun Sep 19, 2021 12:19 pm
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

Re: Scene Event works only once

Posted: Sun Sep 19, 2021 1:40 pm
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.

Re: Scene Event works only once

Posted: Fri Oct 01, 2021 6:26 am
by DryreL
Hi, I solved the problem, thank you!