Ok so im working on a script for basic attacking animation and for whatever reason the animation repeats even though i added a boolean to change it to false. i cant figure out whats going wrong at this pint
using UnityEngine;
using System.Collections;
public class Player1 : Creature
{
public static Player1 player;
public static bool isAttacking;
public static Transform opponent;
Animation animation;
public AnimationClip attackAnimation;
// Use this for initialization
void Awake()
{
player = this;
animation = GetComponent<Animation>();
isAttacking = false;
}
// Update is called once per frame
void Update()
{
Attack();
}
protected override void Attack()
{
if (Input.GetKeyUp(KeyCode.X))
{
if (opponent != null && Vector3.Distance(opponent.position, transform.position) < range)
{
isAttacking = true;
animation.CrossFade(attackAnimation.name);
// opponent.GetComponent<Enemy>().GetHit(damage);
}
}
if (!animation.IsPlaying(attackAnimation.name))
{
isAttacking = false;
}
}
}