Talking animation loop (Mecanim)

Announcements, support questions, and discussion for the Dialogue System.
harumin
Posts: 29
Joined: Fri Dec 30, 2016 10:43 am

Re: Talking animation loop (Mecanim)

Post by harumin »

How do I hide the continue button while the npc is talking and show it only after the npc is done talking or the player decide to press space to skip the line?
User avatar
Tony Li
Posts: 22062
Joined: Thu Jul 18, 2013 1:27 pm

Re: Talking animation loop (Mecanim)

Post by Tony Li »

harumin wrote:How do I hide the continue button while the npc is talking and show it only after the npc is done talking or the player decide to press space to skip the line?
You can use the SetContinueMode() sequencer command. Or, if you're using a script, manually hide the continue button. Let's say this is your sequence:

Code: Select all

AnimatorPlay(Talk);
AnimatorPlay(Idle)@{{end}}
Change it to this:

Code: Select all

SetContinueMode(false);
AnimatorPlay(Talk);
AnimatorPlay(Idle)@{{end}};
SetContinueMode(original)@{{end}}
SetContinueMode(false) hides the continue button. SetContinueMode(original) restores the continue button to its previous state.

Note that this hides it and disables it. Since it's disabled, you may want to assign the space key to the Dialogue Manager's Input Settings > Cancel Key so the player can still skip ahead by pressing space.
harumin
Posts: 29
Joined: Fri Dec 30, 2016 10:43 am

Re: Talking animation loop (Mecanim)

Post by harumin »

Should I make SetContinueMode(false); and SetContinueMode(original)@{{end}} at the default sequence? Because I want on all of my nodes
User avatar
Tony Li
Posts: 22062
Joined: Thu Jul 18, 2013 1:27 pm

Re: Talking animation loop (Mecanim)

Post by Tony Li »

Yes. Add it to any other commands in your Default Sequence (if any).

Actually, this is a better one:

Code: Select all

SetContinueMode(false);
AnimatorPlay(Talk);
required AnimatorPlay(Idle)@{{end}};
required SetContinueMode(original)@{{end}}
The "required" keyword guarantees that the command runs even if the player cancels early.
harumin
Posts: 29
Joined: Fri Dec 30, 2016 10:43 am

Re: Talking animation loop (Mecanim)

Post by harumin »

Thanks Tony :) I have varying talking animations for every characters. Instead of adding the required AnimatorPlay(Idle)@{{end}}; I'll add it instead on the node where the npc talks. Thanks a lot :)
User avatar
Tony Li
Posts: 22062
Joined: Thu Jul 18, 2013 1:27 pm

Re: Talking animation loop (Mecanim)

Post by Tony Li »

Happy to help! If it becomes tedious to add to many nodes, let me know. I might be able to suggest a way to automate it a bit.
harumin
Posts: 29
Joined: Fri Dec 30, 2016 10:43 am

Re: Talking animation loop (Mecanim)

Post by harumin »

Does Persistent Active data save the changes in background images? For example the player goes to the library, the background picture changes into a library by SetActive(Library,true); and when I save to that point and load it back, does it save the inactive and active background images?
User avatar
Tony Li
Posts: 22062
Joined: Thu Jul 18, 2013 1:27 pm

Re: Talking animation loop (Mecanim)

Post by Tony Li »

It doesn't save the changes on its own. You can combine it with the SetVariable() sequencer command, though. For example, to change the background from Street to Library:

Code: Select all

SetActive(Street,false);
SetActive(Library,true);
SetVariable(ShowStreet,false);
SetVariable(ShowLibrary,true)
(In your dialogue database, define variables "ShowStreet", "ShowLibrary", etc.)

For each background image, add a Persistent Active Data component to the scene. Assign the background image, and set the Condition > Lua Condition to something like this for the Persistent Active Data for the Street image:

Code: Select all

Variable["ShowStreet"] == true
harumin
Posts: 29
Joined: Fri Dec 30, 2016 10:43 am

Re: Talking animation loop (Mecanim)

Post by harumin »

Does the variable need to be in boolean?
User avatar
Tony Li
Posts: 22062
Joined: Thu Jul 18, 2013 1:27 pm

Re: Talking animation loop (Mecanim)

Post by Tony Li »

No, that was just an example. I suppose you could define one variable named BackgroundImage. Set the Type to Text. Then set the value to the name of the image that should be active:

Use Library image:

Code: Select all

SetActive(Street,false);
SetActive(Library,true);
SetVariable(BackgroundImage,Library)
In the Persistent Active Data component for the Library image, check this Lua condition:

Code: Select all

Variable["BackgroundImage"] == "Library"
Use Street image:

Code: Select all

SetActive(Street,true);
SetActive(Library,false);
SetVariable(BackgroundImage,Street)
In the Persistent Active Data component for the Street image, check this Lua condition:

Code: Select all

Variable["BackgroundImage"] == "Street"
Post Reply