I have set up the animator for a character in a 3D game. I then set some conditions to change the animation. In this case, I want the character to change from attack=0 (running) to attack=3 (attacking). It works sometimes, oddly, but most of the times the character is stuck in running animation.
There are some extras on the code, for example, reducing the speed to 0 and checking for a certain script. But I'd like to focus the help on the animation changing part.

I tried enlarging the condition to change the animation but it is not working so far.

```
if (anim.GetInteger("attack") == 0)
        {
            if (transform.position.x > 2f && transform.position.x < 3.5f && transform.position.z == 0 ||
            transform.position.z > -3.5f && transform.position.z < -2f && transform.position.x == 0 ||
            transform.position.x > -3.5f && transform.position.x < -2f && transform.position.z == 0 ||
            transform.position.z > 2f && transform.position.z < 3.5f && transform.position.x == 0)
            {
                if (gameObject.GetComponent<LeftNPCmove>() != null)
                {
                    var go = this.gameObject;
                    var com = go.GetComponent<LeftNPCmove>();
                    com.speed -= com.speed;
                    anim.SetInteger("attack", 3);

                }

```

With the first conditions clause I intend to make the character change animation between the interval specified.
In the second conditions clause I tell it to change the condition in the animator from 0 to 3, thus attacking.
Thanks in advance.