Exemple #1
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.transform.name == "Zero")
        {
            //if (collision.otherCollider.usedByComposite)
            //{

            zeroBehavior zero = collision.collider.GetComponent <zeroBehavior>();
            if (zero != null)
            {
                zero.takeDamage(damage);
            }
            //}
        }
    }
    private void OnTriggerEnter2D(Collider2D collision)
    {
        rayCastCheckHit = Physics2D.Raycast(rayCasting1.position, rayCasting1.right, rayCastCheckDistance, whatIsEnemy);

        if (collision.transform.name == "Zero" || Time.time - lastShotTime > 6)
        {
            Debug.Log(collision.name);
            Destroy(gameObject);
        }
        zeroBehavior zero = collision.GetComponent <zeroBehavior>();

        if (zero != null)
        {
            zero.takeDamage(damage);
        }
    }