- Home /
Prevent animation from starting the first time
Hey, I have a character who attacks when left-clicking. I figured out how to prevent him attacking when there is a dialogue going on but at the last continue click the animation starts. I have no idea how to prevent this: https://youtu.be/Opv3xSahBKM I don't want him to attack immediately after the conversation is finished. Only when the conversation is completely finished, should he be able to attack. I'm new to game development and english isn't my first language, so I'm sorry,
How do you trigger the attack...putting some simple if() on it to check whether a conversation has finished should do just fine
public class PlayerCombat : MonoBehaviour
{
public Animator animator;
void Update()
{
if (Input.GetKeyDown(KeyCode.Mouse0))
{
Attack();
}
}
void Attack()
{
animator.SetTrigger("Attack");
}
}
you are not checking if the dialogue is currently playing...you need a reference to your dialogue script....and then an if() statement to check if it's currently displaying any dialogues.....if it's not..that's only when you want to call the Attack() Method
Your answer
Follow this Question
Related Questions
issue rendering animation on button click 1 Answer
Animation not working when UI buttons are pressed 0 Answers
Animate GUI Elements 1 Answer
Calling another script for an animation 1 Answer
Material Design Menu 1 Answer