Page 2 of 3
Re: Talking animation loop (Mecanim)
Posted: Sun Mar 19, 2017 11:54 pm
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?
Re: Talking animation loop (Mecanim)
Posted: Mon Mar 20, 2017 9:30 am
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.
Re: Talking animation loop (Mecanim)
Posted: Mon Mar 20, 2017 11:19 am
by harumin
Should I make SetContinueMode(false); and SetContinueMode(original)@{{end}} at the default sequence? Because I want on all of my nodes
Re: Talking animation loop (Mecanim)
Posted: Mon Mar 20, 2017 11:52 am
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.
Re: Talking animation loop (Mecanim)
Posted: Mon Mar 20, 2017 9:32 pm
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
Re: Talking animation loop (Mecanim)
Posted: Mon Mar 20, 2017 9:41 pm
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.
Re: Talking animation loop (Mecanim)
Posted: Fri Mar 24, 2017 12:28 pm
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?
Re: Talking animation loop (Mecanim)
Posted: Fri Mar 24, 2017 1:08 pm
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:
Re: Talking animation loop (Mecanim)
Posted: Fri Mar 24, 2017 8:46 pm
by harumin
Does the variable need to be in boolean?
Re: Talking animation loop (Mecanim)
Posted: Fri Mar 24, 2017 8:49 pm
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"