Focus/Unfocus animation doesn't work on portraits with separately animated parts

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
ioruko
Posts: 5
Joined: Thu Aug 20, 2020 12:10 pm

Focus/Unfocus animation doesn't work on portraits with separately animated parts

Post by ioruko »

Hello, I have a question about Focus/Unfocus animation.

I set up a Dialogue Panel with two Subtitle Panels (Subtitle Panel 0 and Subtitle Panel 1);
both panels have child objects like Portrait Name and Portrait Image (0 and 1 respectively);
and those Portrait Images have child objects: Portrait Image Eyes and Portrait Image Mouth.

The animated portraits work as expected. But when I want to play Focus/Unfocus animation, it doesn't affect the Portrait images.

Both Subtitle Panel 0 and 1 have Animator component with Canvas Group Animator Controller assigned.
The Focus animation changes the Color property of the Subtitle Panel from 50%gray to white.
(I changed it from affecting the alpha of a Canvas Group).
Unity_cRSjyOCbS4.png
Unity_cRSjyOCbS4.png (31.68 KiB) Viewed 828 times
Unity_PmTlk8lp9H.png
Unity_PmTlk8lp9H.png (29.99 KiB) Viewed 828 times
When I try to add a Color property (Image component) in Focus animation for the Portrait Image (ie the child object of the Subtitle Panel) it adds it, but I cant change it due to the fact that Portrait image has it's own Animator Controller assigned (that animates the character portrait and its parts). So when I click on it, it shows me the animations of another Animator Controller.

I was able to animate Portrait Names on Focus/Unfocus, but can't do the same with Portrait Images.
Interestingly enough, if I animate the Alpha of the Canvas Group component on a Subtitle Panel, it seems to work well enough (but I don't want a semi-transparent portrait, I want it slightly darkened).

Please, can you help understand why this doesn't work. I am a newbie still, so maybe I'm missing something.
I will add screenshots in attachments.
Attachments
6CHfV8GT70.png
6CHfV8GT70.png (431.72 KiB) Viewed 828 times
fKeYiO4cbl.png
fKeYiO4cbl.png (430.72 KiB) Viewed 828 times
User avatar
Tony Li
Posts: 22054
Joined: Thu Jul 18, 2013 1:27 pm

Re: Focus/Unfocus animation doesn't work on portraits with separately animated parts

Post by Tony Li »

Hi,

You can still configure Subtitle Panel 0's animator to animate Portrait Image 0's Image color, even if Portrait Image 0's animator controls the sprites that are playing on the Image. Here's an updated example:

DS_AnimatedPortraitExample_2020-09-03.unitypackage

I only set up the focus animation for Subtitle Panel 0.
ioruko
Posts: 5
Joined: Thu Aug 20, 2020 12:10 pm

Re: Focus/Unfocus animation doesn't work on portraits with separately animated parts

Post by ioruko »

Thanks, I checked it and it looks like the Focus animation only works on the background of the portrait. And the Portrait Image itself is not changing its color (so it's the same situation I have right now, only I don't have a background for my portraits).
User avatar
Tony Li
Posts: 22054
Joined: Thu Jul 18, 2013 1:27 pm

Re: Focus/Unfocus animation doesn't work on portraits with separately animated parts

Post by Tony Li »

I'll update the example later today with an animation that also applies to the additional images.
User avatar
Tony Li
Posts: 22054
Joined: Thu Jul 18, 2013 1:27 pm

Re: Focus/Unfocus animation doesn't work on portraits with separately animated parts

Post by Tony Li »

This updated example tints the color of the main portrait image and the "eyes" child image of NPC Subtitle Panel 0:

DS_AnimatedPortraitExample_2020-09-04.unitypackage

Examine the Focus animation for that subtitle panel, in particular how it sets the colors of the main image and eyes image. It also has keyframes to change the canvas group's alpha, but I removed the canvas group from the subtitle panel since you said you didn't want fading, so those keyframes will be ignored.
ioruko
Posts: 5
Joined: Thu Aug 20, 2020 12:10 pm

Re: Focus/Unfocus animation doesn't work on portraits with separately animated parts

Post by ioruko »

Thanks so much for your reply! I was able to make Focus animation work in my game, thanks to some valuable insight from your example.

But I'm not sure what goes wrong every time, this is in your example (I didn't change there anything):
Unity_uQRdrBtEde.png
Unity_uQRdrBtEde.png (203.73 KiB) Viewed 798 times
So only the eyes are tinted at all times.
The portrait itself stays the same (only background changes color).
Unity_Q7K2jxqxWY.png
Unity_Q7K2jxqxWY.png (192.01 KiB) Viewed 798 times
Just letting you know about it. My problem is fixed thanks to you, so there's no need to adjust the example just for me.
I use Unity 2020.1.2f1
User avatar
Tony Li
Posts: 22054
Joined: Thu Jul 18, 2013 1:27 pm

Re: Focus/Unfocus animation doesn't work on portraits with separately animated parts

Post by Tony Li »

Hmm, I must have missed an animation file or something when I exported it. Anyway, glad you got things working in your project!
shortlin
Posts: 73
Joined: Wed Jun 03, 2020 1:52 am

Re: Focus/Unfocus animation doesn't work on portraits with separately animated parts

Post by shortlin »

Hi Tony.Thank you make the example let me modified to make the different animation's purpose .

I just have a little problem want to ask is when you call the function "AnimatorPlay(Talk, Portrait Image 0);" in a node sequence,the name "Portrait Image 0" really should not be all the same name in the hierarchy?(means "Portrait Image 0" "Portrait Image 1" and "Portrait Image 2" all change the name "Portrait Image")I tried to do this thing,but it would let the function not work when I call the second Portrait(means after I changed the name,I use "AnimatorPlay(Talk, Portrait Image);" to let the second portrait talk,it not work,but the first portrait worked).

I must name the different name that could let the function work.I just want to know is there some way could let me call the same name.(Because I think it should be worked,although maybe you have your considerations )

Just because if the talk function have different functions would let the scrip writer confuse..I am trying to help him lessen the burden.
User avatar
Tony Li
Posts: 22054
Joined: Thu Jul 18, 2013 1:27 pm

Re: Focus/Unfocus animation doesn't work on portraits with separately animated parts

Post by Tony Li »

The AnimatorPlay() sequencer command requires a unique GameObject name. This is why you need to specify Portrait Image 0, Portrait Image 1, etc.

You could write a custom sequencer command to play an animation on the current speaker's portrait image.

I plan to add a new sequencer command to do that in version 2.3.0. Version 2.2.10 is releasing today, and version 2.3.0 will release in about 2 weeks.
Post Reply