Hello, I have been trying to create a combat system and I ran into a problem with input. If I use GetKey it works,but if I use GetKeyDown it stops working. I checked if my if statements were working and the one with input stops working the moment I change GetKey to GetKeyDown. Any idea why this might be happening? Code: (It is my first time asking a question here and it kept marking my code red and saying I need to correct the form but idk what’s wrons so the code is just in text sorry)
void Update()
{
if(timeBtwAttack <= 0)
{
if(Input.GetKey(KeyCode.Mouse0))
{
Debug.Log("Mouse0Down") ;
playerAnim.SetTrigger("Attack");
Collider2D[] enemiesToDamage = Physics2D.OverlapCircleAll(attackPos.position,attackRange,whatIsEnemy);
for (int i = 0; i< enemiesToDamage.Length; i++){
enemiesToDamage*.GetComponent<Enemy>().TakeDamage(damage);*
}
Collider2D[] enemyProgectiles = Physics2D.OverlapCircleAll(attackPos.position,attackRange,whatIsProjectile);
for (int i = 0; i< enemyProgectiles.Length; i++){
enemyProgectiles*.GetComponent().DestroyThis();}*
}
timeBtwAttack = startTimeBtwAttack;
}
else
{ // Debug.Log(“Mouse0Up”) ;
timeBtwAttack-=Time.deltaTime;
playerAnim.SetBool(“AttackExit”, true);
}
}
Edit: I have tried using Get(Mouse)ButtonDown and Get(Mouse)Button and it is exactly the same as GetKey stuff