Playing an animation upon starting a dialogue
-
- Posts: 73
- Joined: Tue Jul 25, 2023 1:34 am
Playing an animation upon starting a dialogue
Hi again ...
I think I've seen this tutorial somewhere, but I can't seem to find it. I'm trying to have an animation play out when a certain dialogue is triggered.
Is there a difference when I need to have the animation play on loop and when I want the animation to only play once?
I think I've seen this tutorial somewhere, but I can't seem to find it. I'm trying to have an animation play out when a certain dialogue is triggered.
Is there a difference when I need to have the animation play on loop and when I want the animation to only play once?
Re: Playing an animation upon starting a dialogue
Hi,
Use the AnimatorPlay() or AnimatorPlayWait() sequencer command to play animations.
Say your speaker has an Animator component. Its animator controller asset has two states: Idle and Dance.
If you want Idle to play on loop, inspect the Idle state's animation clip. Make sure the Loop checkbox is ticked. To play this in a specific dialogue entry node, use the sequencer command AnimatorPlay(Idle), such as:
(Reminder: The keyword {{default}} tells the sequence to also play the Dialogue Manager's Default Sequence.)
If you want to play the Dance animation and wait for it to finish, use AnimatorPlayWait(Dance). Let's say Dance has an automatic transition to Idle when it's done:
Then use this sequence:
When it's done, the Dance state's transition arrow will make sure the Animator goes back to the Idle state.
If you didn't have that transition arrow (which might not be appropriate in all cases), you could use a more advanced syntax for your sequence:
In this case, the AnimatorPlayWait() command sends the sequencer message "DoneDancing" when it's done. This message is an arbitrary string of your choosing.
The AnimatorPlay() command below it waits for the "DoneDancing" sequencer command. Then it runs. The "required" keyword guarantees that it will run even if the player skips ahead before the Dance animation is done.
Use the AnimatorPlay() or AnimatorPlayWait() sequencer command to play animations.
Say your speaker has an Animator component. Its animator controller asset has two states: Idle and Dance.
If you want Idle to play on loop, inspect the Idle state's animation clip. Make sure the Loop checkbox is ticked. To play this in a specific dialogue entry node, use the sequencer command AnimatorPlay(Idle), such as:
Code: Select all
{{default}};
AnimatorPlay(Idle)
If you want to play the Dance animation and wait for it to finish, use AnimatorPlayWait(Dance). Let's say Dance has an automatic transition to Idle when it's done:
Then use this sequence:
Code: Select all
{{default}};
AnimatorPlayWait(Dance)
If you didn't have that transition arrow (which might not be appropriate in all cases), you could use a more advanced syntax for your sequence:
Code: Select all
{{default}};
AnimatorPlayWait(Dance)->Message(DoneDancing);
required AnimatorPlay(Idle)@Message(DoneDancing)
The AnimatorPlay() command below it waits for the "DoneDancing" sequencer command. Then it runs. The "required" keyword guarantees that it will run even if the player skips ahead before the Dance animation is done.
-
- Posts: 73
- Joined: Tue Jul 25, 2023 1:34 am
Re: Playing an animation upon starting a dialogue
What if I do not want an animation linked to a speaker per say? I'm still having trouble with panels and I just think it would be easier if I just had it where I invoked an animation for a separate element
if it's not possible, I'll look into things with the first panel
if it's not possible, I'll look into things with the first panel
Re: Playing an animation upon starting a dialogue
Hi,
You can specify a GameObject to play the animation on. For example, say you have a GameObject named "Door" with Animator that has "Open" and "Close" animations. To play the Open animation:
You can specify a GameObject to play the animation on. For example, say you have a GameObject named "Door" with Animator that has "Open" and "Close" animations. To play the Open animation:
Code: Select all
AnimatorPlay(Open, Door)
-
- Posts: 73
- Joined: Tue Jul 25, 2023 1:34 am
Re: Playing an animation upon starting a dialogue
Awesome! So if I had an animator play the door opening and have an automatic transition to where it goes to idle, I assume the door stays on screen then?
Re: Playing an animation upon starting a dialogue
Yup! For a door, you probably don't even need an Idle. Just Open and Close states.
-
- Posts: 73
- Joined: Tue Jul 25, 2023 1:34 am
Re: Playing an animation upon starting a dialogue
Hi, so I was trying to add the animator bit, but I feel like I'm messing up a whole lot
Basically, I was thinking of creating a blur effect by just taking a picture of the background and creating a blurred image. I would keep the image transparent until a dialogue and just play blur animation to turn on the transparency to full.
I do not know what's going on cause it's just not working, haha.
Basically, I was thinking of creating a blur effect by just taking a picture of the background and creating a blurred image. I would keep the image transparent until a dialogue and just play blur animation to turn on the transparency to full.
I do not know what's going on cause it's just not working, haha.
Re: Playing an animation upon starting a dialogue
Hi,
It looks like your animator controller doesn't have a state named "Fade to Blur".
If your GameObject is named "Blur", try this sequencer command:
If your GameObject is named "Fade to Blur", then try:
It looks like your animator controller doesn't have a state named "Fade to Blur".
If your GameObject is named "Blur", try this sequencer command:
Code: Select all
AnimatorPlay(Blur, Blur)
Code: Select all
AnimatorPlay(Blur, Fade to Blur)
-
- Posts: 73
- Joined: Tue Jul 25, 2023 1:34 am
Re: Playing an animation upon starting a dialogue
thank you, blur, blur works, but now it won't stay in the blurred state where the image remains blur. Instead it cuts to the original idle state.
What can I do?
What can I do?
-
- Posts: 73
- Joined: Tue Jul 25, 2023 1:34 am
Re: Playing an animation upon starting a dialogue
never mind blur blur stopped working ... ugh