Exemplo n.º 1
0
    private void OnTriggerExit2D(Collider2D collider)
    {
        GameObject other = collider.gameObject;
        GrabZone   g     = other.GetComponent <GrabZone>();

        if (g != null)
        {
            g.RemoveGrabbable(this);
        }
    }
Exemplo n.º 2
0
    public void GrabObject()
    {
        Grabbable toGrab = gz.GetGrabbable();

        if (toGrab != null)
        {
            Vector3 holdPos = holdSpot.transform.position;
            float   headY   = ec.points[1].y + ec.offset.y + transform.position.y;
            holdPos.y = headY + toGrab.GetSize().y / 2;
            holdSpot.transform.position = holdPos;
            if (CanMoveGrabbable(toGrab, holdPos))
            {
                gz.RemoveGrabbable(toGrab);
                heldObject = toGrab;
                toGrab.transform.parent = holdSpot.transform;
                toGrab.PickUp(holdPos);
                //TODO: set animstate to carrying? can just check if heldObject != null
            }
        }
    }