void OnCollisionEnter2D(Collision2D p_collision)
    {
        Collider2D collider = p_collision.collider;

        bool hitEntity = false;

        if (collider.gameObject != gameObject)
        {
            CollisionRelay relay = collider.GetComponent <CollisionRelay>();

            if (relay != null && m_shooter != null && relay.m_entity.tag != m_shooter.tag)
            {
                m_shooter.Damage(this, relay.m_entity);

                hitEntity = true;
            }
        }

        if (m_info.m_piercing && hitEntity)
        {
            Physics2D.IgnoreCollision(p_collision.otherCollider, collider);
        }
        if (!m_info.m_piercing || !hitEntity)
        {
            Disable(true);
        }
    }
Beispiel #2
0
    void OnCollisionEnter2D(Collision2D p_collision)
    {
        Collider2D collider = p_collision.collider;
        bool       hit      = false;

        if (collider.gameObject != gameObject)
        {
            CollisionRelay relay = collider.GetComponent <CollisionRelay>();

            if (relay != null && m_shooter)
            {
                m_shooter.Damage(this, relay.m_damageable);

                hit = true;
            }
        }

        if (m_info.m_piercing && hit && collider.transform.parent.tag == "NoProjCollision")
        {
            Disable(true);
        }
        if (m_info.m_piercing && hit)
        {
            Physics2D.IgnoreCollision(p_collision.otherCollider, collider);
        }
        if (collider.tag != "NoProjCollision" && (!m_info.m_piercing || !hit))
        {
            Disable(true);
        }
    }