# Unity3D Problem Temporarily Stop Players Movement When Playing a specific Animation

This is my first time in Unity3D and programming so forgive me if i'm a bit vague on this. I'm working on my own project in Unity3D but I couldn't get the player to stop moving when I press the key. I avoided using the GetButton since it triggered the animation to play twice. After bout 2 hours, I still can't find any answer to my problem.

Here's part of the code of the the player script.

    if (Input.GetButtonDown("Fire1"))
{
animator.SetTrigger("AttackSword");
Debug.Log("Animation called");
}

if(!animator.GetBool("AttackSword"))
{
Move(inputDir, running);
}


If you would like me to add the full code of the script, let me know.

• I see you're using both SetTrigger and GetBool with the same variable name. Which kind of variable is it, a boolean, or a trigger? – DMGregory Jun 6 '18 at 10:10
• @DMGregory i'm using a trigger to activate it. – DigitalWolf Jun 6 '18 at 12:11
• Ah, that will do it. Triggers don't have a persistent 'On" state that can last over a period of time, like a boolean does. They're an instantaneous signal to start a transition. – DMGregory Jun 6 '18 at 12:14
• @DMGregory I understand that but the problem i'm facing is that, how do I set the trigger to true aka "On" state temporarily so that the player stops moving while the attack animation plays? The GetButton causes the animation to run twice for some reason like I said above. The GetButtonDown enables the animation to run, but doesn't enable the trigger state to true. I was wondering if there was any way or alternative that I can use to overcome this problem. – DigitalWolf Jun 6 '18 at 12:29

    if (!this.animator.GetCurrentAnimatorStateInfo(0).IsName("AttackSword"))