Exemple #1
0
    private void CheckInteract()
    {
        if (Input.GetKeyDown(KeyCode.E))
        {
            bool interacted = false;
            if (!torchAction.currentlyHeld)
            {
                interacted = torchAction.Pickup();
                if (interacted && sfx)
                {
                    sfx.clip = pickupSound;
                    sfx.Play();
                }
            }


            if (!interacted)
            {
                //Test for interactable
                Collider[] hitColliders = Physics.OverlapBox(InteractZone.transform.position + InteractZone.center, InteractZone.size / 2, Quaternion.identity, CanInteractWith);
                //if found activate it
                foreach (Collider c in hitColliders)
                {
                    interacted = true;
                    Interactible inter = c.GetComponent <Interactible>();
                    inter.ActivateInteraction();
                    if (sfx)
                    {
                        sfx.clip = interactSound;
                        sfx.Play();
                    }
                }
            }

            //Still nothing? attempt drop
            if (!interacted)
            {
                torchAction.Drop();
            }
            else //Also notify Animator
            {
                _Anim.SetTrigger("Pickup");
            }
        }
    }