Hello,
So I'd like to trigger the facial expressions and animations for a game object sprite instead of one in the UI. The tutorial shows how to do this for UI animations only, as far as I can tell.
1. To change the expressions for a scene game object, would the best way to go about it be to use the scene events in the inspector for the conversation?
2. Is there any way trigger the talking animation on the sprite game object to match the length of the typewriter effect of each conversation block?
Thanks for your help!
Triggering the animations for a game object sprite instead of a UI sprite
Re: Triggering the animations for a game object sprite instead of a UI sprite
Hi,
The answer to both questions is to use cutscene sequences.
For example, say the speaker's game object sprite has an Animator with animator states named "Idle" and "Talk". You can use this sequence to play the Talk animation while the typewriter is typing:
The answer to both questions is to use cutscene sequences.
For example, say the speaker's game object sprite has an Animator with animator states named "Idle" and "Talk". You can use this sequence to play the Talk animation while the typewriter is typing:
Code: Select all
AnimatorPlay(Talk);
required AnimatorPlay(Idle)@Message(Typed)
Re: Triggering the animations for a game object sprite instead of a UI sprite
Thank you for the reply, Tony!
Should there be parameters to trigger Idle and Talk? Right now it looks like the code just seems to make the character Talk nonstop but the Idle doesn't ever trigger. I'm using this code:
Not sure what I'm doing wrong.
Should there be parameters to trigger Idle and Talk? Right now it looks like the code just seems to make the character Talk nonstop but the Idle doesn't ever trigger. I'm using this code:
Code: Select all
AnimatorPlay(Talk);
required Animator.Play(Mouth_Idle)@Message(Typed)
- Attachments
-
- Screenshot states.png (35.31 KiB) Viewed 237 times
Re: Triggering the animations for a game object sprite instead of a UI sprite
Hi,
Check the Console window for warnings.
Also try changing this line:
to this:
(Remove the "." between Animator and Play.)
You don't need any parameters for this. AnimatorPlay() tells the animator to play a state directly, without the need for parameter-based transition arrows.
Check the Console window for warnings.
Also try changing this line:
Code: Select all
required Animator.Play(Mouth_Idle)@Message(Typed)
Code: Select all
required AnimatorPlay(Mouth_Idle)@Message(Typed)
You don't need any parameters for this. AnimatorPlay() tells the animator to play a state directly, without the need for parameter-based transition arrows.
Re: Triggering the animations for a game object sprite instead of a UI sprite
Thanks, I can't believe I did that lol! (I also put the two animations in opposite spots in the code.)
I did fix the spelling error and I was still having issues. It took a while for me to figure out since I'm still new to Unity, but it seems like what was causing issues was the fact that I had a transition from the talk animation to mouth_idle in the animator. Any transitions between mouth_idle and talk seems like it made those animations only play once, instead of the entire time the text was being typed. I guess it was something I didn't understand in terms of how animation works in Unity, but leaving this here in case some one has the same problem.
Thank you again!
I did fix the spelling error and I was still having issues. It took a while for me to figure out since I'm still new to Unity, but it seems like what was causing issues was the fact that I had a transition from the talk animation to mouth_idle in the animator. Any transitions between mouth_idle and talk seems like it made those animations only play once, instead of the entire time the text was being typed. I guess it was something I didn't understand in terms of how animation works in Unity, but leaving this here in case some one has the same problem.
Thank you again!