AnimatorPlayWait() not waiting for state to end

Announcements, support questions, and discussion for the Dialogue System.
User avatar
FlaconiaUnited
Posts: 14
Joined: Fri Oct 02, 2020 2:07 pm

AnimatorPlayWait() not waiting for state to end

Post by FlaconiaUnited »

Hi!
My compliments to you Toni fo this amazing plugin and forum! :D

Time has come to ask for your help for the first time, cause I believe there's something I'm missing here...

The project I'm working on has one single, big dialogue that contains many conversations. We're treating every conversation as a separate scenario that appears one after the other, forming a randomly generated story.
What I'm trying to do is having a short UI transition between these scenarios that informs the user the current scenario ended and he's now in a new one.

I tried putting an AnimatorPlayWait command in the last state of the first introductory conversation:

Code: Select all

AnimatorPlayWait(Hide_to_left, Dialogue Panel);
where Hide_to_left is the trigger that plays an animation state, and DIalogue Panel is the object containing the animator with the state I'm activating. I used it cause what I want to achieve is the animation gets played completely (it's a basic fade out and transition to the left), and after it finishes, goes on with the conversation and automatically goes back to the show state with a fade in.
-
dialogue panel animator.png
dialogue panel animator.png (29.29 KiB) Viewed 330 times
-
What happens instead is, the Hide_to_left animation gets triggered correctly, the panel disappears but then reappears in the middle of the transition in its original position, while the new subtitle panel starts on top of it with the new scenario.
-
dialogue panel hide to left.gif
dialogue panel hide to left.gif (132.07 KiB) Viewed 330 times
-
So, since I believe the AnimatorPlayWait command works (otherwise we would have encountered quite a bug here :lol: ) there must be something else messing with the correct waiting time.
Here's the conversation line that triggers it:
-
return sequencer commands.png
return sequencer commands.png (36.35 KiB) Viewed 330 times
-

I hope the situation is clear enough, thanks a lot for your help!
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: AnimatorPlayWait() not waiting for state to end

Post by Tony Li »

Hi,

If you keep an Animator window open on the Dialogue Panel during play, what state is it in when it shows the wrong thing?

Could it be transitioning to Show when you don't want it to?

BTW, you might consider using the SetDialoguePanel() sequencer command. It shows and hides the Dialogue Panel properly. People often use it to hide the Dialogue Panel during an in-conversation cutscene where nothing is being spoken.
User avatar
FlaconiaUnited
Posts: 14
Joined: Fri Oct 02, 2020 2:07 pm

Re: AnimatorPlayWait() not waiting for state to end

Post by FlaconiaUnited »

Hi Toni!

First of all, thanks for your time.

I tried using the SetDialoguePanel() command as you suggested, but it seems to break the conversation somehow, leaving the subtitle panel deactivated, despite having a command a few steps away that should reactivate it. This is the command right now:
-
return sequence setdialoguepanel false.png
return sequence setdialoguepanel false.png (74.26 KiB) Viewed 322 times
-
-
It's connected to a point of the main conversation:
-
progress check.png
progress check.png (100.28 KiB) Viewed 322 times
-
Since it's the first time playing, it enters the first time scenario on the left, where I also set the dialogue panel true again:
-
first time scenario.png
first time scenario.png (82.96 KiB) Viewed 322 times
-
and this is what's inside it:
-
first time scenario inside.png
first time scenario inside.png (68.04 KiB) Viewed 322 times
-
-
So at this point I should have everything reactivated again, but this is the result, with the Dialogue Panel's Animator at runtime on the right:
-
setdialoguepanel false animator.gif
setdialoguepanel false animator.gif (872.35 KiB) Viewed 322 times
-
-
On top of this, hiding it is not exactly the action I'm trying to perform, it should be more of a transition animation between scenes, I haven't properly designed it yet, it could also be a normal slid to the side, without actually being hidden or made transparent.
I thought AnimatorPlayWait was exactly the function I needed, since if later I want to change the transition, I just go and edit the clip, without doing anything else, bit it really looks like there's some sort of script overriding that thing. I even tried with a Delay in the sequencer command line, it gets totally ignored. As soon as I press the continue button or my choice, it instantly starts typewriting the next scene.
User avatar
FlaconiaUnited
Posts: 14
Joined: Fri Oct 02, 2020 2:07 pm

Re: AnimatorPlayWait() not waiting for state to end

Post by FlaconiaUnited »

Here's how the animator works if activated manually by me during gameplay:
-
animator manually activated.gif
animator manually activated.gif (805.25 KiB) Viewed 322 times
-
-
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: AnimatorPlayWait() not waiting for state to end

Post by Tony Li »

Hi,

Thanks for that GIF. I see what you're trying to do now. Don't use SetDialoguePanel().

AnimatorPlayWait() should work, so let's figure out what's going on.

If you keep an Animator window open on it, does it prematurely jump to the Show state or something like that?

Does the problem only occur when you use the continue button to interrupt the line, or does it also happen unattended?
User avatar
FlaconiaUnited
Posts: 14
Joined: Fri Oct 02, 2020 2:07 pm

Re: AnimatorPlayWait() not waiting for state to end

Post by FlaconiaUnited »

Hey Toni,

this is what happens to the Dialogue Panel, with the Animator open, after removing the SetDialoguePanel and putting back the AnimatorPlayWait():
-
animator with animatorplaywait.gif
animator with animatorplaywait.gif (789.7 KiB) Viewed 313 times
-
-
Basically, there's 2 main problems that prevent me from having the desired effect:
  1. The Show trigger gets triggered continuously at the beginning by something, even after the conversation has already started and the panel is already visible. Notice how it stays active in the trigger list until the first attempt of transition, and then stops being triggered.
    -
  2. The next scenario starts being typewritten while the transition is still going. I enlarged the animation on purpose to make it clear. Notice how after the line "You wander along the path..." the transition gets played correctly but when the panel appears, it already contains all the text, without showing the typewriter effect (that got played while the panel was still being transparent).
    -
-
I believe that the fact thet the Show trigger remains active until the first transition, prevents the first transition to play correctly, and after that every other trigger works fine. So what I did was adding an initial state where the panel is Hidden, and to enter the show state it needs to "cosume" that initial trigger (it was probably meant to work like that since the beginning :lol: ).
Here's the new animator with the new situation:
-
animator new with initial hidden state.gif
animator new with initial hidden state.gif (482.71 KiB) Viewed 313 times
-
-
So now the first problem looks solved, but the second is still there. The typewriter effct should start AFTER the Hide_to_left state finishes...
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: AnimatorPlayWait() not waiting for state to end

Post by Tony Li »

Hi,

If you tick the subtitle panel's 'Delay Typewriter Until Open' checkbox, does the typewriter behave the way you want?
User avatar
FlaconiaUnited
Posts: 14
Joined: Fri Oct 02, 2020 2:07 pm

Re: AnimatorPlayWait() not waiting for state to end

Post by FlaconiaUnited »

Sorry for the late reply, in the meantime we updated Unity...

No, I tried by ticking that option, but it doesn't make any difference.
This is the hierarchy of the dialogue prefab:
-
mountain dialogue UI prefab.png
mountain dialogue UI prefab.png (15.36 KiB) Viewed 306 times
-
-
The option you told me to activate is in the PC Subtitle Panel object, while I'm applying the effect to a parent object, the Dialogue Panel object, that's because I want to make the entire panel scroll, buttons included.

I also tried by temporarly apply the transition to the Subtitle panel directly, to check if that optrion worked, but it doesn't. Just makes no difference.
This is the Inspector of the Subtitle Panel Script:
-
subtitle panel inspector.png
subtitle panel inspector.png (57.44 KiB) Viewed 306 times
-
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: AnimatorPlayWait() not waiting for state to end

Post by Tony Li »

FlaconiaUnited wrote: Mon Oct 05, 2020 1:39 pmThe option you told me to activate is in the PC Subtitle Panel object, while I'm applying the effect to a parent object, the Dialogue Panel object, that's because I want to make the entire panel scroll, buttons included.
Got it. Then that option won't work, as you've seen.

Try this:

Code: Select all

AnimatorPlayWait(Hide_to_left, Dialogue Panel)->Message(Hidden);
AnimatorPlayWait(Show,Dialogue Panel)@Message(Hidden)
If you do this, you can get rid of the transition arrow from Hide_to_left to Show.

If that doesn't work, you may need to make a tiny subclass of StandardUISubtitlePanel that overrides the SetContent() method to wait until the Dialogue Panel is in the state you want.
User avatar
FlaconiaUnited
Posts: 14
Joined: Fri Oct 02, 2020 2:07 pm

Re: AnimatorPlayWait() not waiting for state to end

Post by FlaconiaUnited »

Hello Toni!

I tried putting those 2 sequence commands to the PROGRESS CHECK state (a state that stays always between scenarios) but no changes; I also tried to create a dedicated animator for the PS Subtitle Panel, with same states and triggers of the Dialogue Panel, but different clips that do nothing but last the same number of frames, so that I could apply a fake, empty animation to the PC Sub. as well, deactivating it after the PlayWait but nothing...

The dialogue manager just skips immediately to the next line ignoring everything.

About scripting the subclass, could you give me more details?
Should I duplicate the SetContent subclass, rename it and trigger that new one instead of the original SetContent?

should I just change the conditions nedeed to enter the IF/ELSE to that specific state of the animator?
Post Reply