Пример #1
0
        // Triggering the interactions
        void OnGUI()
        {
            // If jumping or falling, do nothing
            //if (!character.onGround) return;

            // If an interaction is paused, resume on user input
            if (interactionSystem.IsPaused() && interactionSystem.IsInSync())
            {
                GUILayout.Label("Press E to resume interaction");

                if (Input.GetKey(KeyCode.E))
                {
                    interactionSystem.ResumeAll();
                }

                return;
            }

            // If not paused, find the closest InteractionTrigger that the character is in contact with
            int closestTriggerIndex = interactionSystem.GetClosestTriggerIndex();

            if (Input.GetKey(KeyCode.L))
            {
                print(closestTriggerIndex);
            }

            // ...if none found, do nothing
            if (closestTriggerIndex == -1)
            {
                return;
            }

            // ...if the effectors associated with the trigger are in interaction, do nothing
            if (!interactionSystem.TriggerEffectorsReady(closestTriggerIndex))
            {
                return;
            }

            // Its OK now to start the trigger
            GUILayout.Label("Press E to start interaction");

            if (Input.GetKey(KeyCode.E) || (Input.GetButton("L2")))
            {
                interactionSystem.TriggerInteraction(closestTriggerIndex, false);
            }
        }