private void OnTriggerEnter2D(Collider2D collision) { if (collision.tag == "Player") { playerHp.PlayerHit(); } }
void Fire() { if (nextAttack - Time.time <= 1f && nextAttack - Time.time > 0f) { } if (Time.time >= nextAttack) { RaycastHit2D hit = Physics2D.Raycast(transform.position, direction, distance, mask); if (hit.collider != null) { PlayerHpScript healthToDamage = hit.collider.GetComponent <PlayerHpScript>(); healthToDamage.PlayerHit(); randomCooldown = Random.Range(2f, 5f); nextAttack = Time.time + randomCooldown; } else { randomCooldown = Random.Range(2f, 5f); nextAttack = Time.time + randomCooldown; } } }
public void BiteAttack() //Deals damage to the player when an animationen event triggers this function { attackAudio.Play(); playerHp.PlayerHit(); }