// void OnCollisionEnter2D (Collision2D collision) void OnTriggerEnter2D(Collider2D collider) { Debug.Log("OnCollisionEnter2D : " + collider.gameObject.name + ", " + collider.gameObject.tag); if (collider.gameObject.tag == "PlayerShoot") { ShootMovement data = (ShootMovement)collider.gameObject.GetComponent(typeof(ShootMovement)); m_fEnege -= data.getPower(); if (m_fEnege < 0) { EnemyMovement movement = GetComponent <EnemyMovement>(); movement.m_fSpeed = 2.0f; m_anim.SetBool("isDestroy", true); this.tag = "Untagged"; } else { data.actionDestroy(); } } }
private void Awake() { shootMov = FindObjectOfType <ShootMovement>(); }