예제 #1
0
    void LeftMouseClicked()
    {
        //if not holding an object already
        if (!objectHeld)
        {
            //send a ray to check if capable of picking up and object
            if (Physics.Raycast(mainCam.transform.position, transform.forward, out hit, rayLength, pickUpObjects))
            {
                //pick up object if found
                objectHeld = true;
                currentObject = hit.collider.gameObject.GetComponent<PickUpObject>();
                currentObject.Clicked();
            }

            else if (Physics.Raycast(mainCam.transform.position, transform.forward, out hit, rayLength, dynamicObjects))
            {

                currentTarget = hit.collider.gameObject.GetComponent<Targetable>();
            if (currentTarget != null)
            {
                currentTarget.Clicked();
            }
        }

        }
        //if we are holding an object
        else
        {
            //release it
            currentActivityObject = null;
            currentObject.Release();
            objectHeld = false;
        }
    }
예제 #2
0
    void RightMouseClicked()
    {
        if (Physics.Raycast(mainCam.transform.position, transform.forward, out hit, rayLength, dynamicObjects))
        {

            currentTarget = hit.collider.gameObject.GetComponent<Targetable>();
            if (currentTarget != null)
            {
                currentTarget.Clicked();
            }
        }
    }