Talking animation loop (Mecanim)
Re: Talking animation loop (Mecanim)
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)
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: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?
Code: Select all
AnimatorPlay(Talk);
AnimatorPlay(Idle)@{{end}}
Code: Select all
SetContinueMode(false);
AnimatorPlay(Talk);
AnimatorPlay(Idle)@{{end}};
SetContinueMode(original)@{{end}}
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)
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)
Yes. Add it to any other commands in your Default Sequence (if any).
Actually, this is a better one:
The "required" keyword guarantees that the command runs even if the player cancels early.
Actually, this is a better one:
Code: Select all
SetContinueMode(false);
AnimatorPlay(Talk);
required AnimatorPlay(Idle)@{{end}};
required SetContinueMode(original)@{{end}}
Re: Talking animation loop (Mecanim)
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)
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)
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)
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:
(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
SetActive(Street,false);
SetActive(Library,true);
SetVariable(ShowStreet,false);
SetVariable(ShowLibrary,true)
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
Re: Talking animation loop (Mecanim)
Does the variable need to be in boolean?
Re: Talking animation loop (Mecanim)
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:
In the Persistent Active Data component for the Library image, check this Lua condition:
Use Street image:
In the Persistent Active Data component for the Street image, check this Lua condition:
Use Library image:
Code: Select all
SetActive(Street,false);
SetActive(Library,true);
SetVariable(BackgroundImage,Library)
Code: Select all
Variable["BackgroundImage"] == "Library"
Code: Select all
SetActive(Street,true);
SetActive(Library,false);
SetVariable(BackgroundImage,Street)
Code: Select all
Variable["BackgroundImage"] == "Street"