コード例 #1
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.tag == "Player")
     {
         playerHp.PlayerHit();
     }
 }
コード例 #2
0
    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;
            }
        }
    }
コード例 #3
0
 public void BiteAttack() //Deals damage to the player when an animationen event triggers this function
 {
     attackAudio.Play();
     playerHp.PlayerHit();
 }