コード例 #1
0
    void OnTriggerEnter2D(Collider2D col)
    {
        Koopa koopa = col.gameObject.GetComponentInParent <Koopa>();

        switch (col.gameObject.tag)
        {
        case "koopa_side_collider":
            if (koopa.GetShellMoving())
            {
                float x = 0.125f;
                if (koopa.GetInShell() && koopa.getXVel() > 0 && GetInShell())
                {
                    enemySpeed *= -1;
                    x          *= -1;
                }

                SetHitByShell(true);

                rigidBody.AddForce(new Vector2(x, 1f), ForceMode2D.Impulse);
                StartCoroutine(Death(2f));
            }
            break;
        }
    }