Пример #1
0
    void CheckInteractions()
    {
        interactable = Physics.SphereCast(head.transform.position, .3f, head.transform.TransformDirection(new Vector3(0, 0, .001f)), out obj, 1f, 1 << LayerMask.NameToLayer("Interactables"));

        if (!interactable)
        {
            interactobj = null;
        }


        if (obj.transform != null)
        {
            interactobj = obj.transform.GetComponent <InteractableObject>();
        }
        if (interactobj != null && interactobj.isActive)
        {
            if (interactobj.type == InteractableObject.Hold && Vector3.Distance(head.transform.position, interactobj.transform.position) > 3.5f)
            {
                interactobj.StopInteract();
                interacting = false;
                interactobj = null;
            }

            if (Inputs.B_Button())
            {
                interactobj.StopInteract();
                interacting = false;
            }
        }
        else if (!interacting && interactobj != null && Inputs.B_Button())
        {
            switch (interactobj.type)
            {
            case 1:
                interactobj.StartInteract(GetComponent <Player>());
                interacting = true;
                break;

            case 2:
                break;

            case 3:
                interactobj.StartInteract(GetComponent <Player>());
                break;

            case 4:
                break;

            default:
                Debug.Log("Unknown Object Type");
                break;
            }
        }
    }