Hi,
gdbaradit wrote: ↑Thu Sep 12, 2019 5:57 pmIf my character goes running against the NPC and press the "Talking key" (In my case, F) the character will keep playing the Running animation. I tried using the solution shown in the Triggers and Interactions video, but it didn't work.
The solution is going to be specific to your character. Identify what makes the Running animation play.
- If it's a script, you will need to use Dialogue System Events to disable the script during conversations.
- If it's an animator parameter such as Speed, you may be able to use Dialogue System Events by assigning the Animator to the event.
- If not, you can use a Dialogue System Trigger set to On Conversation Start. Select Add Action > Play Sequence. Then use one of the Animator***() sequencer commands in the Sequence field to set the parameter to a value that makes the Running animation stop.
It may require a combination. Feel free to post more details about your character here, or send an example project to tony (at) pixelcrushers.com if you want me to take a look directly.
gdbaradit wrote: ↑Thu Sep 12, 2019 5:57 pmPlus, since I'm using shaders for 2D sprites, I have 2 animations for every state: Idle-right, Idle-left, Talking-right, Talking-Left, etc.
How can I get my character to play the idle/talking animations, plus considering the direction they're talking to?
I recommend tackling it in two steps. In the first step, get the character talking regardless of direction. Try setting the Dialogue Manager's Camera & Cutscene Settings > Default Sequence to:
Code: Select all
AnimatorPlay(Talking-right);
required AnimatorPlay(Idle-right)@{{end}}
(Make sure the spelling and capitalization exactly matches your animator states.)
This will make the characters play Talking-right as soon their line starts. After a duration based on the text length, they will play the Idle-right animation.
If only your player has these animations, you can set Default Player Sequence instead.
If you have questions about sequences, watch at least part 1 of the
Cutscene Sequence Tutorials. Parts 2 & 3 are useful, too. You can probably skip the rest for now.
---
Once you have that working, here's a discussion about playing animations with directions:
Personally, I think it might be easier to let the Animator know which animations to play. Let's say you have an animator parameter named "Left". When the character is facing left, the parameter is true. When the character is facing right, the parameter is false. Then you can add trigger parameters named Idle and Talk. If Talk is triggered and Left is true, transition to Idle-Left. If Talk is triggered and Left is false, transition to Idle-Right. This way, as long as you've been setting the Left parameter when the character turns left or right, you can just set the Talk trigger to make the character talk in the appropriate direction. Then set the Default Sequence to:
Code: Select all
AnimatorTrigger(Talk);
required AnimatorTrigger(Idle)@{{end}}
The Dialogue System doesn't need to know anything about left/right direction in this case.
If you don't want to do that, and if you want to make the Dialogue System handle it, you can define and set a Dialogue System variable to the player's current direction. In C# script, you can do something like this:
Code: Select all
PixelCrushers.DialogueSystem.DialogueLua.SetVariable("Dir", "left"); // Player is facing left.
In this case, I'll assume that you're keeping the Dialogue System variable "Dir" up to date as the player turns left & right.
Then set the Default Player Sequence to:
Code: Select all
AnimatorPlay(Talking-[var=Dir]);
required AnimatorPlay(Idle-[var=Dir])@{{end}}
gdbaradit wrote: ↑Thu Sep 12, 2019 5:57 pmBonus Question: Everytime I start the game, the Writer Effect Audio plays twice and then stops for reasons unknown to me.... What could it be?
You're talking about the typewriter effect on your subtitle panels' text elements, right? If so, inspect the Audio Source component on the same GameObject and untick Play On Awake. If the GameObject doesn't have an Audio Source component, add one and untick Play On Awake.