void OnTriggerEnter2D(Collider2D c) { // *It is compared with name in order to separate as Asset from project settings. // However, it is recommended to use Layer or Tag. if (c.name.Contains(NAME_PLAYER_BULLET)) { UbhSimpleBullet bullet = c.transform.parent.GetComponent <UbhSimpleBullet>(); UbhObjectPool.Instance.ReleaseGameObject(c.transform.parent.gameObject); _Hp = _Hp - bullet._Power; if (_Hp <= 0) { FindObjectOfType <UbhScore>().AddPoint(_Point); _Spaceship.Explosion(); Destroy(gameObject); } else { _Spaceship.GetAnimator().SetTrigger(ANIM_DAMAGE_TRIGGER); } } }
private void OnTriggerEnter2D(Collider2D c) { // *It is compared with name in order to separate as Asset from project settings. // However, it is recommended to use Layer or Tag. if (c.name.Contains(NAME_PLAYER_BULLET)) { UbhPlayerBullet playerBullet = c.transform.parent.GetComponent <UbhPlayerBullet>(); if (playerBullet != null && playerBullet.isActive) { UbhObjectPool.instance.ReleaseBullet(playerBullet); m_hp = m_hp - playerBullet.m_power; if (m_hp <= 0) { FindObjectOfType <UbhScore>().AddPoint(m_point); m_spaceship.Explosion(); Destroy(gameObject); } else { m_spaceship.GetAnimator().SetTrigger(ANIM_DAMAGE_TRIGGER); } } } }