Re: Cannot find dialog behavior I really want for 2d Game
Posted: Sat Nov 26, 2016 3:37 pm
In case you haven't managed to get your animated portraits to obey your commands (I had some issues with mine) here is what I discovered, doing a bit of reverse engineering in Toni's example.
When I created my first animated portraits I did the following:
1- Add "Use Animated Portraits" script to Dialogue UI
2- Add "Animated Portraits" scripts to all NPC, assign an animator controller with respective animations to all of the "Animated Portraits" scripts.
3-Assign NPCs to each conversation.
Following these steps, it was all working perfect, one animation playing for the whole length of a speaker's line. But what happened if I wanted to change an animated expression? Or if I wanted my characters to stop speaking after a reasonable lapse?
I used the sequencer command recommended by Tony in the camera settings of my Dialogue Manager. This stops the talking animation after a period related to the speaker's line length.
AnimatorPlay(Talking, NPC Portrait Image);
AnimatorPlay(Idle, NPC Portrait Image)@{{end}}
And that was it. Nothing worked again, I got all kinds of error messages, starting from "-1 is not a valid layer index", could not find the GoTo state in my animations, the animator didn't have a controller, etc. Eventually I got everything working again, but I had to add an animator component to the Portrait Image in my Dialogue UI ( (I assigned one of the animator controllers of my NPCs, it works regardless of which one I use, as long as there is one).
I also had to correct another minute detail. My UI doesn't have NCP Portrait Image, but only Portrait Image, so I adjusted this in the default sequence in the Camera Settings of my Dialogue Manager and that seemed to fix the remaining error messages.
AnimatorPlay(Talking, Portrait Image);
AnimatorPlay(Idle, Portrait Image)@{{end}}
Now, I thought to get the animations to go from one state to another (say for different expressions) I had to use:
AnimatorPlay(State, Character, duration of cross-fade, layer index)
Example:
AnimatorPlay(Angry, Julianne, , -1)
Here I got informed that my NPC (Julianne) doesn't have an animator component. She does, in fact. But I got it to work with:
AnimatorPlay(Angry, Portrait Image,, 0)
This worked just fine for me and I hope this helps you a bit. In any case, I am going to post a more detailed description in my dev's blog (to remember it in the future!):
https://thestchristopherslockdown.wordpress.com/
When I created my first animated portraits I did the following:
1- Add "Use Animated Portraits" script to Dialogue UI
2- Add "Animated Portraits" scripts to all NPC, assign an animator controller with respective animations to all of the "Animated Portraits" scripts.
3-Assign NPCs to each conversation.
Following these steps, it was all working perfect, one animation playing for the whole length of a speaker's line. But what happened if I wanted to change an animated expression? Or if I wanted my characters to stop speaking after a reasonable lapse?
I used the sequencer command recommended by Tony in the camera settings of my Dialogue Manager. This stops the talking animation after a period related to the speaker's line length.
AnimatorPlay(Talking, NPC Portrait Image);
AnimatorPlay(Idle, NPC Portrait Image)@{{end}}
And that was it. Nothing worked again, I got all kinds of error messages, starting from "-1 is not a valid layer index", could not find the GoTo state in my animations, the animator didn't have a controller, etc. Eventually I got everything working again, but I had to add an animator component to the Portrait Image in my Dialogue UI ( (I assigned one of the animator controllers of my NPCs, it works regardless of which one I use, as long as there is one).
I also had to correct another minute detail. My UI doesn't have NCP Portrait Image, but only Portrait Image, so I adjusted this in the default sequence in the Camera Settings of my Dialogue Manager and that seemed to fix the remaining error messages.
AnimatorPlay(Talking, Portrait Image);
AnimatorPlay(Idle, Portrait Image)@{{end}}
Now, I thought to get the animations to go from one state to another (say for different expressions) I had to use:
AnimatorPlay(State, Character, duration of cross-fade, layer index)
Example:
AnimatorPlay(Angry, Julianne, , -1)
Here I got informed that my NPC (Julianne) doesn't have an animator component. She does, in fact. But I got it to work with:
AnimatorPlay(Angry, Portrait Image,, 0)
This worked just fine for me and I hope this helps you a bit. In any case, I am going to post a more detailed description in my dev's blog (to remember it in the future!):
https://thestchristopherslockdown.wordpress.com/