Hi!
Short answer:
Use "@
time", such as:
Code: Select all
AnimatorInt(Greeting,1);
AnimatorInt(Greeting,0)@2
This sets the Greeting parameter to zero at the 2-second mark.
Long answer:
Let's get this out of the way first: If you'd rather use a visual sequence editor such as SLATE or Cinema Director, use the corresponding sequencer command as described in the
Third Party Support section of the manual. For example, say you've created a cutscene named "Play Greeting" in SLATE's visual editor. Set the dialogue entry node's Sequence field to: SLATE(Play Greeting).
For most sequences, however, many devs prefer to use the Dialogue System's text-based sequencer commands because we can stay in the flow of writing without having to switch to a different type of editor and mindset for each dialogue entry node.
Now that that's out of the way, here's the crash course on sequences. It's a lot of info, so if you have any questions about it please let me know. But once you're familiar with everything below you'll know basically everything there is to know about sequences.
Timing Sequencer Commands
Sequences consist of a list of sequencer commands. In a sequence,
all sequencer commands will try to run immediately unless they have an "@" sign to specify when they should run. (See
this page for more info about "@" and syntax in general.) Here's an example:
Code: Select all
AnimatorInt(Greeting,1);
AnimatorInt(Greeting,0)@2
This sequence consists of two AnimatorInt commands. The first command runs immediately and sets Greeting to 1. The second command runs at the 2-second mark and sets Greeting to 0.
There's another way to use the "@" sign: "@Message(
someMessage)". This syntax tells a command to wait for a sequencer message before running. For example, the Dialogue System's Tutorial Example has a dialogue entry similar to this:
- Dialogue Text: Pick up a red box.
- Sequence:
This dialogue entry waits until the sequencer receives a message "GotRedBox" from a script. Then it plays the audio clip "Hurray". (The script uses the static method Sequencer.Message(
string).)
You can combine this with one more syntax: "->Message(
someMessage)". This syntax sends a sequencer message when a command finishes. Here's an example:
Code: Select all
AnimatorPlayWait(Curtsy)->Message(DoneGreeting);
AnimatorPlay(Idle)@Message(DoneGreeting)
The first sequencer command plays the Curtsy animator state and waits for it to finish. When it's done, it sends a sequencer message "DoneGreeting".
The second sequencer command waits for the "DoneGreeting" message. When it receives this message, it plays the Idle animator state.
Sequences Outside Dialogue Entries
The Dialogue System provides some helper components that can play sequences.
Sequence Trigger plays a sequence when a general Unity event occurs, such as OnStart or OnTriggerEnter.
Start Sequence On Dialogue Event plays a sequence when a Dialogue System event occurs, such as OnConversationStart or OnConversationEnd.
Start Sequence On Dialogue Event is frequently used with character controllers. Very often, character controllers set animator parameters such as "Speed" or "Forward" that need to be set to zero at the beginning of a conversation to make the character stop. To do this, you can add a Start Sequence On Dialogue Event component to the character. Set the Trigger to OnConversation, and add an element to the OnStart list.
This post has an example for Unity's Standard Assets ThirdPersonController.
If you're using Unity's ThirdPersonController and want to stop the character and also play a greeting animation for 1.5 seconds, you could set the OnStart sequence to something like:
Code: Select all
AnimatorFloat(Forward,0);
AnimatorFloat(Turn,0);
AnimatorInt(Greeting,1);
AnimatorInt(Greeting,0)@1.5
Similarly, if you always want the character to play an animation at the end of any conversation, you could set the OnEnd sequence to something like:
Code: Select all
AnimatorInt(WaveGoodbye,1);
AnimatorInt(WaveGoodbye,0)@2
(Wave goodbye for 2 seconds.)