Sequence in dialogue triggering animation on another object

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
chrislow19
Posts: 34
Joined: Mon Dec 30, 2019 4:26 pm

Sequence in dialogue triggering animation on another object

Post by chrislow19 »

Hi Tony, have a bit of a question for you. I'd like to set an animation on a separate gameobject to trigger once I hit a certain point in a conversation. My character Shirley will force a tree to disappear after a dialogue node with the boolean Shirley.tree set to true. At which point, the prioritycamera will focus on the tree as it fades for maybe 3 seconds, and the gameobject is disabled afterward. I'm not entirely certain where the sequence would go. In the dialogue node? On the tree itself? How is the dialogue sequence supposed to trigger the other gameobject to do these things?

Thanks ahead of time Tony.
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: Sequence in dialogue triggering animation on another object

Post by Tony Li »

Hi Chris,

Use the dialogue entry node's Sequence.

For example, let's say the tree's GameObject is named "Maple Tree". It has an Animator with an animator state named "Disappear". Set the Sequence field to something like:

Code: Select all

AnimatorPlay(Disappear, Maple Tree);
Delay(3)
AnimatorPlay() finds the GameObject named "Maple Tree" and tells its Animator to play the state named "Disappear". Delay(3) stays on that dialogue entry node for 3 seconds before progressing to the next stage of the conversation.

The AnimatorPlayWait() command, on the other hand, waits for the animator state to finish. You could do this instead:

Code: Select all

AnimatorPlayWait(Disappear, Maple Tree)
Since you mention a prioritycamera, it sounds like you're using Cinemachine. You can use the CinemachinePriority() command to set the priority of a vcam. For example:

Code: Select all

CinemachinePriority(Tree vcam, 999);
AnimatorPlayWait(Disappear, Maple Tree)->Message(TreeDisappeared);
CinemachinePriority(Tree vcam, 0);@Message(TreeDisappeared)
The first line sets the priority of "Tree vcam" to 999.

The second line plays the disappear animation. When it's done, it sends the sequencer a message "TreeDisappeared".

The third line waits until the sequencer receives the message "TreeDisappeared". Then it sets the Tree vcam's priority back down to zero.
chrislow19
Posts: 34
Joined: Mon Dec 30, 2019 4:26 pm

Re: Sequence in dialogue triggering animation on another object

Post by chrislow19 »

Hi Tony, thanks a lot, that worked! For future reference, do you have a documented list of all the sequencer commands with explanation? And is referencing a separate object generally in the 2nd spot in parenthesis on other sequencer commands (if it's being used)?

Thanks again
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: Sequence in dialogue triggering animation on another object

Post by Tony Li »

Yup!
If third party integrations add new sequencer commands, they'll be documented on the integration's page. List of integrations: Third Party Integration
Post Reply