I want to stop movement of my Character while i call any animation like Kick Punch etc.. Please help,

public GameObject Player;
//public bool isRuning;
public float xMove;
public float yMove;
//private Rigidbody myBody;
private Animator anim;
void Walk(bool move)
{
anim.SetBool(“Movement”, move);
}

    void Awake()
    {
      //  myBody = GetComponent<Rigidbody>();
        anim = GetComponent<Animator>();
    }

    void FixedUpdate()
    {
        PlayerMovement();
        AnimatePlayerWalk();
        PunchAnimation();
        KickhAnimation();
    }

    public void PlayerMovement()
    {
        xMove = Input.GetAxis("Horizontal") * Time.deltaTime * 200;
        yMove = Input.GetAxis("Vertical") * Time.deltaTime * 5;
        yMove = Mathf.Clamp01(yMove); // mathf.clamp01 will move char forward but not backward

        transform.Rotate(0, xMove, 0);
        transform.Translate(0, 0, yMove);
        }
    
    
    public void AnimatePlayerWalk()
    {
        if (Input.GetAxisRaw("Horizontal") != 0 ||
                Input.GetAxisRaw("Vertical") > 0)
        {
            Walk(true);
        }
        else
        {
            Walk(false);
        }
    }
    public void PunchAnimation()
    {
        if (Input.GetKeyDown(KeyCode.Z))
        {
            anim.SetTrigger("Punch1");
            transform.Translate(0, 0, 0);
        }
       else if (Input.GetKeyDown(KeyCode.X))
        {
            anim.SetTrigger("Punch2");
            transform.Translate(0, 0, 0);
        }   
    }
    public void KickhAnimation()
    {
        if (Input.GetKeyDown(KeyCode.C))
        {
            anim.SetTrigger("Kick1");
            transform.Translate(0, 0, 0);
        }
        else if (Input.GetKeyDown(KeyCode.V))
        {
            anim.SetTrigger("Kick2");
             transform.Translate(0, 0, 0);
        }
    }
}

If you have a separate script for movement (you should really make one, keeping scripts organized helps in the long run, even if you have more in the end) and then disable the movement script while the kick is active. Example I stole from someone else because Im not gonna try and find it in my scripts lol. GameObject.Find(“Player”).GetComponent().enabled = false; btw player refers to whatever your movement script is on and PlayerMovement is the script itself If anything doesn’t work tell me and Ill dig through my scripts! cheers!

Hi zoystudios,
you should put the decisions/if-statements in context to each other, so e,g

         void FixedUpdate()
         {
			 if (Input.GetKeyDown(KeyCode.Z))
			 {
				Punch1Animation(); 
			 } 
			 else if (Input.GetKeyDown(KeyCode.X))
			 {
				Punch2Animation(); 
			 } 
			 .
			 .
			 .
			 else {
				 PlayerMovement();
				 AnimatePlayerWalk();
			 }
         }

and maybe you want one method per key, so you don’t have to make the same decision twice:

         public void Punch1Animation()
         {
			 anim.SetTrigger("Punch1");
			 transform.Translate(0, 0, 0);
         }
         
         public void Punch2Animation()
         {
			 anim.SetTrigger("Punch2");
			 transform.Translate(0, 0, 0);
         }

This way you just need to be aware, that you’re priorising the keys questioned in the upper if statements. In the example, if you press X and Z, always Punch1 gets executed.
Hope it helps.