questions about "Delay()" and "Continue()@"

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Noodle_Soup
Posts: 12
Joined: Mon Nov 20, 2017 11:38 pm

questions about "Delay()" and "Continue()@"

Post by Noodle_Soup »

Hi,

First of all, thank you for creating this asset, Dialogue System has been a blessing for my last project before I graduate from a Video Game Design major, now... I'm having a few issues using Delay() within a sequence (not totally sure, maybe I'm doing something wrong).

I'm trying this right now:

Sequence:

Code: Select all

AnimatorPlayWait(State_AnimIN, Sprite);                     //lasts 1sec
Delay(4.5);
AnimatorPlayWait(State_AnimOUT, Sprite)                 //lasts 1sec
The animation used for both states is the same and lasts 1 second, but when I reach that node, the first one plays immediately, as expected... But, the delay is being ignored, and the second animations also plays immediately, it doesn't even wait for the first one to finish.

Instead of doing that I switched to using two nodes and Continue()@ :

First one:

Code: Select all

AnimatorPlayWait(State_AnimIN, Sprite);             //lasts 1sec
Continue()@2
Followed by:

Code: Select all

AnimatorPlayWait(State_AnimOUT, Sprite);       //lasts 1sec
Continue()@2 
My question being, "how can I achieve what I did with the last two nodes, but only using one?" I thought using Delay() was the proper way to do it, I'm not sure, maybe I'm missing something.

Thanks for taking your time reading this. :)
User avatar
Abelius
Posts: 318
Joined: Fri Jul 21, 2017 12:45 pm

Re: questions about "Delay()" and "Continue()@"

Post by Abelius »

Hello and welcome!

I'm sure Tony will reply to you far better than me, but in the meantime,I can tell you that sequence commands are run all at the same time, regardless of their position in the list. I had the same misunderstanding at first, probably because they're called "sequence" commands... :roll:

That said, you could delay their execution by adding a @seconds suffix, like this...:

Code: Select all

AnimatorPlayWait(State_AnimIN, Sprite);
AnimatorPlayWait(State_AnimOUT, Sprite)@5.5;
I'm assuming that you want to wait 4.5 seconds between the first and second animations, so those 5.5 seconds account for the first animation play time also.

However, take into account that if the player clicks the continue button before a delayed command is run, then it won't run it at all. So if that second animation needs to be played, no matter what, add the required prefix to it, like this...:

Code: Select all

AnimatorPlayWait(State_AnimIN, Sprite);
required AnimatorPlayWait(State_AnimOUT, Sprite)@5.5;
I think you should be fine with this... but do what Tony tells you. Always. :lol:
Unity 2019.4.9f1
Dialogue System 2.2.15
User avatar
Tony Li
Posts: 22056
Joined: Thu Jul 18, 2013 1:27 pm

Re: questions about "Delay()" and "Continue()@"

Post by Tony Li »

Abelius' answer is spot-on. (Thanks!)

You can also use the "->Message" and "@Message" syntax, like this:

Code: Select all

AnimatorPlayWait(State_AnimIN, Sprite)->Message(InDone);
required AnimatorPlayWait(State_AnimOUT, Sprite)@Message(InDone)
The "->Message(x)" syntax sends a message x, which can be any string of your choosing.

The "@Message(x)" syntax tells the sequencer command to wait for a message x.

In the example above, the AnimatorPlayWait(State_AnimIN, Sprite) command sends the message "InDone" when it's done. The next command waits until it receives this message -- except if the player cancels the subtitle early, the "required" keyword ensures that the animation plays.

You can also send a sequencer message in your own scripts using Sequencer.Message(x). The Tutorial Example scene does this. It waits for the player to pick up colored blocks in order to progress the conversation.
Noodle_Soup
Posts: 12
Joined: Mon Nov 20, 2017 11:38 pm

Re: questions about "Delay()" and "Continue()@"

Post by Noodle_Soup »

Abelius wrote: Tue Nov 21, 2017 5:06 am You could delay their execution by adding a @seconds suffix, like this...:
Yay, works like a charm!
Abelius wrote: Tue Nov 21, 2017 5:06 am However, take into account that if the player clicks the continue button before a delayed command is run, then it won't run it at all. So if that second animation needs to be played, no matter what, add the required prefix to it, like this...:
I had no idea about that, thanks for telling me. I'm using it right now, just in time.

Finally I have time to reply. Thanks a lot, both of you. Now I'm placing @Seconds everywhere, it's way better than having a hundred nodes for very large sequence, at least for me...

Also, not sure if this is the proper way but, I'd like to ask another thing (yeah, instead of creating another topic, maybe I should...) I have a bunch of quests, and all of them start as "unassigned", and part of my conversations already have big branches, depending on the status of those quests... One of them needs this condition:


Condition

Code: Select all

CurrentQuestState("Quest") == "unassigned"
But even if Quest/Item has "Quest" as "unassigned", that certain path is unnavailable, unless I use:

Script

Code: Select all

SetQuestState("Setting_scores", "unassigned")

manually before reaching that node. only that what the path appears as true. Am I supposed to do it like that or maybe I'm using the wrong variable, makes me curious.

Again, thank you for your help. :)
User avatar
Tony Li
Posts: 22056
Joined: Thu Jul 18, 2013 1:27 pm

Re: questions about "Delay()" and "Continue()@"

Post by Tony Li »

Please double-check that the quest name in CurrentQuestState("xxx") is correct.

Is it possible that you changed the quest name and didn't update the Conditions on this dialogue entry node? To avoid having to update Conditions, you can tick the quest's Use Display Name checkbox and specify a Display Name. Keep the Name unchanged, since this is how you'll refer to the quest internally such as in Conditions. But you can change Display Name as much as you want, and you can even change it at runtime.

Also, using the "..." dropdown menus as much as possible instead of manually typing into the Conditions and Script fields helps to avoid typos in case that ends up being the issue.
Noodle_Soup
Posts: 12
Joined: Mon Nov 20, 2017 11:38 pm

Re: questions about "Delay()" and "Continue()@"

Post by Noodle_Soup »

Okay... I've been checking the database and found this:

Image

I don't know when or how, but I have two states for the quest, and if I try CurrentQuestState("test") == "0" it works , but if I switch to "unassigned", It doesn't. for some reason most of my quests have two states... Except for three. :S

-----

Oh boy... Okay, looks like I've messed up the quest template:

Image

I'll try deleting the second state from the array so I can try again with "unassigned", hope it works. u.u

EDIT: Now it works, that was it.
User avatar
Tony Li
Posts: 22056
Joined: Thu Jul 18, 2013 1:27 pm

Re: questions about "Delay()" and "Continue()@"

Post by Tony Li »

Good catch. That was a tricky one.
Post Reply