Пример #1
0
    void  OnCollisionEnter2D(Collision2D coll)
    {
        //Check if player is stomping the enemy
        if ((coll.collider.gameObject.tag == "Player") && canStomp == true)          //If it hits the player
        {
            foreach (ContactPoint2D contact in coll.contacts)
            {
                if (stompCollider.GetInstanceID() == contact.otherCollider.GetInstanceID())
                {
                    StartCoroutine(stompTimer());                      //Start timer for next stomp
                    //Debug.Log ("StompCollider hit !");
                    if (playerController == null)
                    {
                        playerController = coll.collider.gameObject.GetComponent <Controller>();                                             //Get controller and Jump
                    }
                    playerController.Jump();
                    hp.AdjustCurrentHealth(-stompDamage);
                }
            }
        }

        //Direction Change check
        if (canRotate == true && coll.collider.gameObject.layer == 11 || coll.collider.gameObject.layer == 13 || coll.collider.gameObject.layer == 14)           //If it hits wall/player/enemy
        {
            foreach (ContactPoint2D contact in coll.contacts)
            {
                if (frontCollider.GetInstanceID() == contact.otherCollider.GetInstanceID())                   //If it collided with the front
                {
                    StartCoroutine(Flip());
                    //Debug.Log ("FrontCollider hit !");
                }
            }
        }
    }
Пример #2
0
    private void Attack(CircleCollider2D col)
    {
        var cols = Physics2D.OverlapCircle(col.bounds.center, col.radius, LayerMask.GetMask("Hitbox"));

        Debug.Log(cols.GetInstanceID() + " : " + AttackBox.GetInstanceID());
    }