Skip to main content
added 16 characters in body
Source Link
klaymen
  • 223
  • 3
  • 10

There's no need to attacking variable. it should work.

public class PlayerAttack : MonoBehaviour {

private bool attacking = false;

public float attackTimer = 0f;
public float attackCD = .3f;

public Collider2D attackTrigger;
Animator anim;

// Use this for initialization
void Start () {
    anim = GetComponent<Animator> ();
    attackTrigger.enabled = false;
    attackTimer = attackCD;//       assign variables
}

// Update is called once per frame
void Update () {
    if (Input.GetKeyDown ("space")) 
    {
         anim.SetBool ("Attack", true);
        attackTimer = attackCD;//assign variables
        attackTrigger.enabled = true;
         if(attackTimer > 0){
            attackTimer -= Time.deltaTime;//Decrease our timer
        }else
        {
            attackTrigger.enabled = false;
             anim.SetBool ("Attack", false);
        }
    }

   
} 

There's no need to attacking variable. it should work.

public class PlayerAttack : MonoBehaviour {

private bool attacking = false;

public float attackTimer = 0f;
public float attackCD = .3f;

public Collider2D attackTrigger;
Animator anim;

// Use this for initialization
void Start () {
    anim = GetComponent<Animator> ();
    attackTrigger.enabled = false;
}

// Update is called once per frame
void Update () {
    if (Input.GetKeyDown ("space")) 
    {
         anim.SetBool ("Attack", true);
        attackTimer = attackCD;//assign variables
        attackTrigger.enabled = true;
         if(attackTimer > 0){
            attackTimer -= Time.deltaTime;//Decrease our timer
        }else
        {
            attackTrigger.enabled = false;
             anim.SetBool ("Attack", false);
        }
    }

   
} 

There's no need to attacking variable. it should work.

public class PlayerAttack : MonoBehaviour {

private bool attacking = false;

public float attackTimer = 0f;
public float attackCD = .3f;

public Collider2D attackTrigger;
Animator anim;

// Use this for initialization
void Start () {
    anim = GetComponent<Animator> ();
    attackTrigger.enabled = false;
    attackTimer = attackCD;//       assign variables
}

// Update is called once per frame
void Update () {
    if (Input.GetKeyDown ("space")) 
    {
         anim.SetBool ("Attack", true);
        
        attackTrigger.enabled = true;
         if(attackTimer > 0){
            attackTimer -= Time.deltaTime;//Decrease our timer
        }else
        {
            attackTrigger.enabled = false;
             anim.SetBool ("Attack", false);
        }
    }

   
} 
Source Link
klaymen
  • 223
  • 3
  • 10

There's no need to attacking variable. it should work.

public class PlayerAttack : MonoBehaviour {

private bool attacking = false;

public float attackTimer = 0f;
public float attackCD = .3f;

public Collider2D attackTrigger;
Animator anim;

// Use this for initialization
void Start () {
    anim = GetComponent<Animator> ();
    attackTrigger.enabled = false;
}

// Update is called once per frame
void Update () {
    if (Input.GetKeyDown ("space")) 
    {
         anim.SetBool ("Attack", true);
        attackTimer = attackCD;//assign variables
        attackTrigger.enabled = true;
         if(attackTimer > 0){
            attackTimer -= Time.deltaTime;//Decrease our timer
        }else
        {
            attackTrigger.enabled = false;
             anim.SetBool ("Attack", false);
        }
    }

   
}