I have trouble with Animator in Unity2d. I have a main character for my game. The character has his own animation clip for fighting. When the player touches the screen, i am starting animation. When the player touches the screen slowly (every second) - everything is working fine, but when the player touches the screen fast, the animation clip is playing about 10 times, and then nothing happens (the clip isn't playing). I've checked - the touch event is triggered normaly, may the problem is with animator. Does anyone have ideas how to fix this issue?
public bool UseAxisInput = false;
private Animator Anim;
// Use this for initialization
void Start () {
Anim = GetComponent<Animator>();
}
// Update is called once per frame
void Update () {
for (var i = 0; i < Input.touchCount; ++i)
{
if (Input.GetTouch(i).phase == TouchPhase.Began)
{
Anim.SetBool("IsFighting", true);
}
}
}
May be this is because of that at the end of my animation i have an animation event which calls the method, that stops animation.
This is my method, that is called, after the animation ends
public void stopFighting()
{
Anim.SetBool("IsFighting", false);
}
Trigger
instead of aBoolean
parameter and scrap theAnimationEvent
completely? \$\endgroup\$