play full animation on click

Hey,

I’m trying to play attack anim onclick, but its playing for 0.1 sec :slight_smile: how can i manage that ?

    void Attack() {
		if(Input.GetMouseButtonDown(0)) {
			karakter.animation.Play("attack");	
		}
	}
	
	// Update is called once per frame
	void Update () {
		if(Input.GetMouseButtonDown(0)) {
			Attack();
		}	
	}

public bool attack = false;

void Update()
{
if(!attack){
if(Input.GetMouseButtonDown(0))
{
StartCoroutine(Attack());
}
}
if(attack)
karakter.animation.CrossFade("attack");
}

IEnumerator Attack()
	{
		attack = true;
		yield return new WaitForSeconds(transform.animation["attack"].length);
		attack = false;
		yield break;
	}

you can simply check animation with boolean and you must break the enumerator funciton if you going to do animation stuff in this function.