Exemplo n.º 1
0
    void CheckDrop()
    {
        int x = Screen.width / 2;
        int y = Screen.height / 2;

        checkRay = mainCamera.GetComponent <Camera>().ScreenPointToRay(new Vector3(x, y));
        RaycastHit hitCheck;

        if (Physics.Raycast(ray, out hitCheck))
        {
            SelectableScript p      = hitCheck.collider.GetComponent <SelectableScript>();
            GameObject       pCheck = p.gameObject;
            if (pCheck != carriedObject)
            {
                DropObject();
            }
        }
    }
Exemplo n.º 2
0
    void PickupObject()
    {
        int x = Screen.width / 2;
        int y = Screen.height / 2;

        ray = mainCamera.GetComponent <Camera>().ScreenPointToRay(new Vector3(x, y));
        RaycastHit hit;

        if (Physics.Raycast(ray, out hit))
        {
            SelectableScript p = hit.collider.GetComponent <SelectableScript>();
            if (p != null)
            {
                carrying      = true;
                carriedObject = p.gameObject;
                p.hoverOn();
                //
            }
        } /*
           * if (Input.GetButtonDown("Fire1"))
           * {
           * int x = Screen.width / 2;
           * int y = Screen.height / 2;
           *
           * Ray ray = mainCamera.GetComponent<Camera>().ScreenPointToRay(new Vector3(x, y));
           * RaycastHit hit;
           * if (Physics.Raycast(ray, out hit))
           * {
           *    SelectableScript p = hit.collider.GetComponent<SelectableScript>();
           *    if (p != null)
           *    {
           *        carrying = true;
           *        carriedObject = p.gameObject;
           *    }
           * }
           * } */
    }