Ejemplo n.º 1
0
    public bool Grab(Grabbable grabbable)
    {
        if (!Grabbing)
        {
            Grabbable = grabbable;
            SpriteRenderer renderer = grabbable.GetComponentInParent <SpriteRenderer>();
            bool           overlap  = Physics2D.OverlapBox(inHandAnchor.transform.position, new Vector2(renderer.bounds.size.x, renderer.bounds.size.y),
                                                           0, getCombineLayerMask(invalidGrabLayers));

            Debug.Log(invalidDropLayers.Count);

            if (!overlap)
            {
                Debug.Log("No overlap"); // Maybe play a sound here indicating an invalid position for grabbing the object
                grabbable.transform.parent.parent        = inHandAnchor.transform;
                grabbable.transform.parent.localPosition = Vector2.zero;

                Grabbing = true;
                return(true);
            }

            Debug.Log("Theres an overlap");
        }

        return(false);
    }