Hello, I have a flashing exclamation point above NPC character's head, and I want it to switch to a "greyed out" version after the player talks to them. I'm trying to add an action in the "Dialogue System Event" tab that changes the animation state of the speech bubble when the player talks to them.
The state starts on 0, and when I change it to 1 manually, it works. But how do I tell the Dialogue system to change the state to 1? There's a bar for me to input the state I want, and I've tried putting "1", "(state, 1)", "AnimatorInt(state, 1)", etc.
Any help is appreciated, thank you.
Changing Animation State Through Dialogue System Trigger
-
- Posts: 60
- Joined: Thu Mar 24, 2022 12:07 am
Re: Changing Animation State Through Dialogue System Trigger
Hi,
UnityEvents such as OnConversationEnd() will let you call an Animator's Play() or SetTrigger() method. This means you can make the animator play a state or set a trigger parameter. Assuming your Animator has states named "0" and "1", you can set up the NPC like this:
Make sure state "1" doesn't automatically transition back to state "0" in the Animator window.
If you need to set an Animator's bool parameter or something else like that, you can use sequencer commands in your conversation. For example, set the last dialogue entry node's Sequence to something like:
UnityEvents such as OnConversationEnd() will let you call an Animator's Play() or SetTrigger() method. This means you can make the animator play a state or set a trigger parameter. Assuming your Animator has states named "0" and "1", you can set up the NPC like this:
Make sure state "1" doesn't automatically transition back to state "0" in the Animator window.
If you need to set an Animator's bool parameter or something else like that, you can use sequencer commands in your conversation. For example, set the last dialogue entry node's Sequence to something like:
- Dialogue Text: "Goodbye."
- Sequence: {{default}}; AnimatorBool(GreyedOut, true)
-
- Posts: 60
- Joined: Thu Mar 24, 2022 12:07 am
Re: Changing Animation State Through Dialogue System Trigger
EDIT: Ok I think it's working now that I've added a SetTrigger string at the end of the dialogue. Idk why that works and everything else didn't, but that's alright, thank you
Thank you,
I set the sequence on the last line of dialogue to:
AnimatorBool(isFlashing, false)
In the animator, there is a condition that if the "isFlashing" bool is false, it will transition to the GreyedOut state.
It is still not working
The game object is called "Exclamation", and I also tried;
Exclamation; AnimatorBool(isFlashing, false)
{Exclamation}; AnimatorBool(isFlashing, false)
{{Exclamation}}; AnimatorBool(isFlashing, false)
I'm guessing I'm typing it wrong or I'm not referencing the game object correctly or something?
Thank you,
I set the sequence on the last line of dialogue to:
AnimatorBool(isFlashing, false)
In the animator, there is a condition that if the "isFlashing" bool is false, it will transition to the GreyedOut state.
It is still not working
The game object is called "Exclamation", and I also tried;
Exclamation; AnimatorBool(isFlashing, false)
{Exclamation}; AnimatorBool(isFlashing, false)
{{Exclamation}}; AnimatorBool(isFlashing, false)
I'm guessing I'm typing it wrong or I'm not referencing the game object correctly or something?
Last edited by DrewThomasArt on Mon Apr 11, 2022 3:40 pm, edited 1 time in total.
Re: Changing Animation State Through Dialogue System Trigger
Hi,
Try this:
If your scene will have more than one GameObject named Exclamation, you might want to add the name of the actor to the GameObject name to make it unique. For example, if the actor is Bob, then name the GameObject "Exclamation Bob" and use:
Try this:
Code: Select all
{{default}}; AnimatorBool(isFlashing, false, Exclamation)
Code: Select all
{{default}}; AnimatorBool(isFlashing, false, Exclamation Bob)
-
- Posts: 60
- Joined: Thu Mar 24, 2022 12:07 am
Re: Changing Animation State Through Dialogue System Trigger
Thank you very much, this works as well as changing the Trigger string with an end of dialogue event like you suggested. It just took me a while to figure it outTony Li wrote: ↑Mon Apr 11, 2022 3:38 pm Hi,
Try this:
If your scene will have more than one GameObject named Exclamation, you might want to add the name of the actor to the GameObject name to make it unique. For example, if the actor is Bob, then name the GameObject "Exclamation Bob" and use:Code: Select all
{{default}}; AnimatorBool(isFlashing, false, Exclamation)
Code: Select all
{{default}}; AnimatorBool(isFlashing, false, Exclamation Bob)