[SOLVED] Animation not working when interacting twice (SMS)

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Kit
Posts: 13
Joined: Thu Jan 05, 2023 11:02 am

[SOLVED] Animation not working when interacting twice (SMS)

Post by Kit »

Hi!

I've been using the SMS template for a dialogue UI I'm currently working on, and I've been attempting to change it up to fit what I need. What I've mainly done is remove the portraits from beside the subtitle text (I disabled the "NPC Portrait Image" and "PC Portrait Image" objects) and instead placed new ones as children of the "Dialogue Panel" object. I have basically copied the ones from the Focus template ("Subtitle Panel 0(NPC)" and "Subtitle Panel 1 (PC)"). Everything works almost exactly as intended the first time I run the conversation, however the second time I try to run it during the same "playthrough", the portraits and names for both the NPC and the player don't show up. After a lot of debugging, I've determined it's the animations that don't start. They stay in the "start" state and never leave there even if I try to play the interaction a third time. I'm using the standard "Canvas Group Animator Controller" and have an Animator placed on the "Subtitle Panel 0 (NPC)", "Subtitle Panel 1 (PC)" (both copied from the Focus template) and one on the "Dialogue Panel". The animation works just fine on the "Dialogue Panel", just not on the subtitle panels.

Other than that, the "focus" and "unfocus" animations don't seem to ever play, and I do have them added in the "Focus Animation Trigger" and "Unfocus Animation Trigger" part of the "Standard UI Subtitle Panel" script that I have attached both to my subtitle panels and "NPC Message Template" and "PC Message Template". Not entirely sure why those two animations just don't work here.

Here's a picture of how my objects are set up:
Image
Last edited by Kit on Thu Jan 12, 2023 9:05 am, edited 1 time in total.
User avatar
Tony Li
Posts: 22137
Joined: Thu Jul 18, 2013 1:27 pm

Re: Animation not working when interacting twice (SMS)

Post by Tony Li »

Here's an example that might get close to what you're looking for. It's an existing example, and I haven't added the animations yet, but it should be able to handle them the way you described:

DS_SMSPlusSidePortraits_2023-01-06.unitypackage
Kit
Posts: 13
Joined: Thu Jan 05, 2023 11:02 am

Re: Animation not working when interacting twice (SMS)

Post by Kit »

Tony Li wrote: Fri Jan 06, 2023 10:44 am Here's an example that might get close to what you're looking for. It's an existing example, and I haven't added the animations yet, but it should be able to handle them the way you described:

DS_SMSPlusSidePortraits_2023-01-06.unitypackage
This isn't quite what I was looking for but thank you for a quick response! I'm going to try to explain it a little better and with some pictures this time.

I pretty much have everything set up the way I want it already, but I can't get the animations to work. Meaning the focus, unfocus (and possible the hide) animations that are premade in the program don't work on the portraits I have made. When I run the code in debug mode, I can see that it does run the code for unfocus and focus, my pictures just are not changing in alpha at all nor are the animations running when I took in the animator window, but the triggers should run as far as I can tell.
Another thing is that if I want to run the same conversation twice, the portraits do not show up the second time around.
Here's some pictures to demonstrate:
First runtime
Image
Second runtime
Image

This is what the animator looks like for the portraits, it just gets stuck in "start" mode:
Image
Here is how I got the animations set up in the Standard UI Subtitle Panel script:
Image

So all in all: Focus, unfocus (and possible hide) animations are not running and once I try to start the conversation a second time no animations run, at least not on portraits or names..

I have an animator on the objects marked with red in the following pictures:
Image
The dialogue panel contains a UI Panel script and the two other objects in the picture both have their own Standard UI Subtitle Panel script.

I hope that explains the issue a little better. Thank you!
User avatar
Tony Li
Posts: 22137
Joined: Thu Jul 18, 2013 1:27 pm

Re: Animation not working when interacting twice (SMS)

Post by Tony Li »

Hi,

The side portraits aren't in the subtitle panels' hierarchies, so the regular Focus/Unfocus Animation Triggers won't work for them. Instead, try configuring the subtitle panels' OnFocus() and/or OnUnfocus() UnityEvents to control their animators. Here's an example that uses OnFocus() to set the speaker's Canvas Group > Alpha to 1 and other NPC's Canvas Group > Alpha to 0.5:

DS_SMSPlusSidePortraits_2023-01-09.unitypackage

You could make an animator controller and change the OnFocus() events to control the animator instead.
Kit
Posts: 13
Joined: Thu Jan 05, 2023 11:02 am

Re: Animation not working when interacting twice (SMS)

Post by Kit »

I found the solution to my issue in your newest example. I can't believe it turned out to be such an easy thing to fix.

Thank you very much for the help and for your time!
User avatar
Tony Li
Posts: 22137
Joined: Thu Jul 18, 2013 1:27 pm

Re: Animation not working when interacting twice (SMS)

Post by Tony Li »

Glad to help!
Post Reply