示例#1
0
    private void toShoot()
    {
        float   centery        = (bc2d.bounds.min.y + bc2d.bounds.max.y) / 2;
        Vector2 positioncenter = new Vector2(bc2d.bounds.min.x - 5, centery);

        RaycastHit2D[] hitscenter = Physics2D.RaycastAll(positioncenter, Vector2.right * -1, 500);
        foreach (RaycastHit2D hit in hitscenter)
        {
            if (hit.collider != null && hit.collider.gameObject.tag == "Spikey")
            {
                GameObject      inst = Instantiate(arrow, rb2d.transform.position + transform.right * -5 + transform.up * 5, arrow.transform.rotation);
                ArrowController bc   = inst.GetComponent <ArrowController>();
                bc.setVelocity(arrowSpeed * -1);
                canShoot = false;
                SoundManager.PlaySound("BoundTrap");
            }
        }
    }