Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetButtonDown("Interact") && lookedAtInteractive != null)
        {
            //Interacts with the looked at interactive object when the button is pressed.
            lookedAtInteractive.InteractWith();
        }

        if (Input.GetButton("Interact") && lookedAtInteractive != null && heldInteractive == null)
        {
            //Sets an object as being the one that's "held".
            heldInteractive = lookedAtInteractive;
            heldInteractive.HoldInteractive(true);
        }

        if (Input.GetButtonUp("Interact") && heldInteractive != null)
        {
            //Removes object from being "held" causing it to drop.
            heldInteractive.HoldInteractive(false);
            heldInteractive = null;
        }
    }