Untitled

mail@pastecode.io avatar
unknown
csharp
2 years ago
848 B
3
Indexable
    void PickUse()
    {
        int x = Screen.width / 2;
        int y = Screen.height / 2;

        Ray ray = mainCamera.ScreenPointToRay(new Vector3(x, y));
        RaycastHit hit;

        if (Physics.Raycast(ray, out hit, pickDistance))
        {
            if(hit.transform.tag == "Pickable")
            {
                pickable = hit.transform.GetComponent<Pickable>();
                carried_rb = pickable.rb;
                carried_rb.interpolation = RigidbodyInterpolation.Interpolate;
                carried_rb.angularDrag = 5;
                isCarrying = true;
            }

             if(hit.transform.tag == "Collectable")
            {
                Debug.Log("We hit mushroom");  // WE GET NOTHING HERE.
                //hit.collider.gameObject.SetActive(false);
            }
        }
    }