Animated Portraits

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
User avatar
Alatriste
Posts: 181
Joined: Wed Nov 11, 2015 5:07 pm
Contact:

Animated Portraits

Post by Alatriste »

Hi all, I'm quite new with Dialogue System and although I managed to understand more or less how the system works, I'm having troubles figuring out how to play animated portraits. I checked the online documentation but it seems to be out of dated (http://www.pixelcrushers.com/dialogue_s ... e_u_i.html), as it doesn't specify how to work with the new Unity UI. I would appreciate some help.

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

Re: Animated Portraits

Post by Tony Li »

Hi,

The documentation for Unity UI has its own page. On the dialogue UI intro page, it's the first link: Unity UI Dialogue UI.

Sorry about the confusion with the other page you referenced. It's an old page that isn't supposed to be referenced by the current documentation. Could you please tell me how you got that page? I'll update the link.

The Unity UI Dialogue UI doesn't have built-in support for animated portraits yet. I was gathering input from users about how they'd like it to work. Here's the candidate for the next release: UnityUIAnimatedPortraits_2015-11-11.unitypackage

It's also on the Extras page.

Documentation will be in the final release. In brief:

1. Add a Use Animated Portraits component to your dialogue UI.

2. Add an Animated Portrait component to each actor.

3. For each actor, create an animator controller that plays a spritesheet animation. Assign it to the actor's Animated Portrait.

4. If you want to change the actor's "mood," you can use the AnimatorPlay or AnimatorTrigger sequencer commands to transition to a different state. For PCs, specify "PC Portrait Image" as the subject of the command. For NPCs, you'll want to duplicate the command and specify "NPC Portrait Image" and "NPC Reminder Portrait Image" as the subjects of the commands.
User avatar
Alatriste
Posts: 181
Joined: Wed Nov 11, 2015 5:07 pm
Contact:

Re: Animated Portraits

Post by Alatriste »

Thanks for your answer Tony. I don't remember how I got there. Maybe through a google search. :?:

I will try the master candidate! ;)
User avatar
Alatriste
Posts: 181
Joined: Wed Nov 11, 2015 5:07 pm
Contact:

Re: Animated Portraits

Post by Alatriste »

Hi all,

I was trying to make work the animated portraits and although I make it work with the animated controller included in the example, when I try to create the animated controller myself, using the same spreed sheet, it doesn't work. The new controller as far I think is working, because I can play the animation in the scene. Am I missing something?
User avatar
Tony Li
Posts: 20685
Joined: Thu Jul 18, 2013 1:27 pm

Re: Animated Portraits

Post by Tony Li »

Hi,

Sorry the official documentation isn't out yet. It'll be available in the next release.

Please check these things:

1. Does your dialogue UI (the GameObject with the UnityUIDialogueUI component) have a Use Animated Portraits component?

2. Does your NPC have an Animated Portrait component? And is the animator controller assigned to it?

3. Does the animator controller start playing the animation right away? In other words, does the default state (orange node) contain the animation you want to play? Is the animation set to Loop Time?

4. When you start the conversation, is the NPC GameObject specified as the conversant? For example, if you're using a Conversation Trigger, the NPC should be assigned it the Conversant field.
User avatar
Alatriste
Posts: 181
Joined: Wed Nov 11, 2015 5:07 pm
Contact:

Re: Animated Portraits

Post by Alatriste »

Thanks Tony! I will give a try although I think the problem is in the animator controller. I will investigate.
User avatar
Tony Li
Posts: 20685
Joined: Thu Jul 18, 2013 1:27 pm

Re: Animated Portraits

Post by Tony Li »

Sounds good! If it's still not behaving, please feel free to send me an example scene. I'll be happy to take a look.
RojasGoni
Posts: 5
Joined: Tue Nov 22, 2016 5:14 pm

Re: Animated Portraits

Post by RojasGoni »

I don't know if by now you fixed the issue, but I had a similar situation and it took me a while to realise that to get the animation to play in the UI it needs to be created within a UI image. Otherwise, if you create the animation on a world game sprite it doesn't work fine. So the steps to get this to happen involve:
1- Create a Game Object of the UI type>Image
2-Assign to the image the sprite you want to use as animated protrait. In reference to this, you don't need to generate a spritesheet, it works just as well if you use a png sequence.
3-Open the animation window.
4- Create an animation, this will generate automatically the animator controller.
5-Bring the other sprites into the timeline.
6-You can now remove the image you created, you won't be needing this at all. But make a mental note of where you have the animation controller, because this is the part which really matters.

If you haven't done the other things discussed in the forum conversation above:

7-Look for the UI assigned to your Dialogue Manager (you fill find it inside the canvas) and add a "Use Animate Portrait" component. If you do the auto search using "Use Animated Portrait" you will get the wrong script attached to your UI ("Animated Portrait", which you will need later) . What you need to do here is to drag the script "Use Animated Portrait" script to the button which says "Add component". You will find this script in the Dialogue System folder in your assets (Scripts>Supplemental>UI>Animated Portraits)
8- In your character, do the same but this time dragging the "Animated Portrait" Script. You will notice a field in the script to receive the animation controller you just created. Put that animation controller in the field and you are done.
9-If you still have any issues, make sure that the name the NPC has is the same in your Dialogue System database and in the game world. Dialogue System is going to look for the character which has the animated portrait script attached, so don't use any abbreviated name or always check for typos.

I hope this helps, it took me a good couple of hours to figure out why my animated portraits were not happening. You were partly right: the example animation controller worked, but not because it was important by itself (you could have created a new one and tested the clip, it did work there too). What really matters is having an animation created in UI space.

Good luck!
User avatar
Tony Li
Posts: 20685
Joined: Thu Jul 18, 2013 1:27 pm

Re: Animated Portraits

Post by Tony Li »

Thanks, @RojasGoni! That's a good writeup. I'll highlight instructions for this process in the next release.
Post Reply