コード例 #1
0
    void OnCollisionEnter2D(Collision2D other)
    {
        Enemy enemy = other.collider.GetComponent <Enemy>();

        if (enemy != null)
        {
            foreach (ContactPoint2D point in other.contacts)
            {
                if (point.normal.y >= 0.9f)
                {
                    FindObjectOfType <AudioManager>().Play("Grounded");
                    m_Rigidbody2D.AddForce(new Vector2(0f, 500));
                    enemy.headDeath = true;
                }
                else
                {
                    if (gameObject.tag == "PlayerHead")
                    {
                        FindObjectOfType <AudioManager>().Play("Grounded");
                        PlayerPosHead playerPosHead = GetComponent <PlayerPosHead>();
                        playerPosHead.isDead();
                    }
                    if (gameObject.tag == "Player")
                    {
                        PlayerPos playerPos = GetComponent <PlayerPos>();
                        playerPos.isDead();
                    }
                }
            }
        }
        EnemyNonVc enemyNonVc = other.collider.GetComponent <EnemyNonVc>();

        if (enemyNonVc != null)
        {
            foreach (ContactPoint2D point in other.contacts)
            {
                if (point.normal.y >= 0.9f)
                {
                    FindObjectOfType <AudioManager>().Play("Grounded");
                    m_Rigidbody2D.AddForce(new Vector2(0f, 500));
                    enemyNonVc.headDeath = true;
                }
                else
                {
                    if (gameObject.tag == "PlayerHead")
                    {
                        FindObjectOfType <AudioManager>().Play("Grounded");
                        PlayerPosHead playerPosHead = GetComponent <PlayerPosHead>();
                        playerPosHead.isDead();
                    }
                    if (gameObject.tag == "Player")
                    {
                        PlayerPos playerPos = GetComponent <PlayerPos>();
                        playerPos.isDead();
                        Debug.Log("SURE");
                    }
                }
            }
        }
    }
コード例 #2
0
    void OnCollisionEnter2D(Collision2D other)
    {
        Enemy enemy = other.collider.GetComponent <Enemy>();

        if (enemy != null)
        {
            foreach (ContactPoint2D point in other.contacts)
            {
                if (point.normal.y >= 0.9f)
                {
                    m_Grounded = false;
                    m_Rigidbody2D.AddForce(new Vector2(0f, 400));
                    enemy.headDeath = true;
                }
                else
                {
                    PlayerPosHead playerPosHead = GetComponent <PlayerPosHead>();
                    playerPosHead.isDead();
                }
            }
        }
    }