public void Update(float deltaTime, PlayerInputScript player) { AttackTimer += deltaTime; player.UpdateAttackInputVariables(AttackTimer >= blockAttackInputTime, AttackTimer > -blockNewAttackTime); if (!hasDamaged && AttackTimer >= damageTime) { Collider2D[] hits = player.ThrowAttack(attackPosition, attackSize); foreach (Collider2D hit in hits) { HealthComponent healthComponent = hit.GetComponent <HealthComponent>(); if (healthComponent != null) { healthComponent.Damage(damage, Vector2.zero); } EnemyHand enemyHand = hit.GetComponent <EnemyHand>(); if (enemyHand != null) { //Debug.Log("Test"); enemyHand.Damage(damage); } } hasDamaged = true; } if (AttackTimer >= attackLength) { player.EndAttack(); } }
//when bullet hits enemy void OnTriggerEnter2D(Collider2D hitInfo) { EnemyHand enemyHand = hitInfo.GetComponent <EnemyHand>(); if (enemyHand != null) { //Debug.Log("Test"); enemyHand.Damage(dmg); } //gets info of object we hit Debug.Log(hitInfo.name); //once we have an enemy time this will call it's take damage function //it takes damage Destroy(gameObject); }