예제 #1
0
    void Water()
    {
        int          layerMask     = 1 << LayerMask.NameToLayer("Interactable");
        Vector2      castDirection = new Vector2(animator.GetFloat("Horizontal"), animator.GetFloat("Vertical"));
        RaycastHit2D hit           = Physics2D.CircleCast(transform.position, waterAOE, castDirection, 0f, layerMask);

        if (hit.collider != null)
        {
            Waterable m = hit.collider.GetComponent <Waterable>();
            if (m)
            {
                m.Watered();
            }
        }
    }
예제 #2
0
    void Water()
    {
        int     layerMask     = 1 << LayerMask.NameToLayer("Interactable");
        Vector2 castDirection = new Vector2(animator.GetFloat("Horizontal"), animator.GetFloat("Vertical"));

        RaycastHit2D[] hits = Physics2D.CircleCastAll((Vector2)transform.position + (castDirection * waterRange), waterAOE, castDirection, 0f, layerMask);
        Instantiate(waterEffect, (Vector2)transform.position + (castDirection * waterRange), Quaternion.identity);
        foreach (RaycastHit2D hit in hits)
        {
            Waterable m = hit.collider.GetComponent <Waterable>();
            if (m)
            {
                m.Watered();
            }
        }
    }