コード例 #1
0
    void OnTriggerEnter2D(Collider2D other)
    {
        Patrol enemy = other.GetComponent <Patrol>();

        if (enemy != null)
        {
            enemy.TakeDamage(damage);
            Instantiate(impactEffect, transform.position, transform.rotation);
        }
    }
コード例 #2
0
    void OnTriggerEnter2D(Collider2D other)
    {
        Patrol enemy = other.GetComponent <Patrol>();

        if (enemy != null)
        {
            enemy.TakeDamage(damage);
            Instantiate(impactEffect, transform.position, transform.rotation);
        }
        if (other.gameObject.tag != "Bullet")
        {
            Destroy(gameObject);
        }
    }
コード例 #3
0
    void OnTriggerEnter2D(Collider2D hitInfo)
    {
        Patrol enemy = hitInfo.GetComponent <Patrol> ();

        if (enemy != null)
        {
            enemy.TakeDamage(damage);
        }

        GameObject explosion = (GameObject)Instantiate(impactEffect, transform.position, transform.rotation);

        Destroy(explosion, 6 / 10f);

        Destroy(gameObject);
    }