Example #1
0
        // Start interaction
        public void Start(InteractionObject interactionObject, string tag, float fadeInTime, bool interrupt)
        {
            // If not in interaction, set effector positions to their bones
            if (!inInteraction)
            {
                effector.position = effector.bone.position;
                effector.rotation = effector.bone.rotation;
            }
            else if (!interrupt)
            {
                return;
            }

            // Get the InteractionTarget
            target = interactionObject.GetTarget(effectorType, tag);
            if (target == null)
            {
                return;
            }
            interactionTarget = target.GetComponent <InteractionTarget>();

            // Start the interaction
            this.interactionObject = interactionObject;
            if (OnStart != null)
            {
                OnStart(effectorType, interactionObject);
            }

            // Posing the hand/foot
            if (poser != null)
            {
                if (poser.poseRoot == null)
                {
                    poser.weight = 0f;
                }

                if (interactionTarget != null)
                {
                    poser.poseRoot = target.transform;
                }
                else
                {
                    poser.poseRoot = null;
                }

                poser.AutoMapping();
            }

            // Reset internal values
            timer       = 0f;
            weight      = 0f;
            fadeInSpeed = fadeInTime > 0f? 1f / fadeInTime: 1000f;
            length      = interactionObject.length;

            triggered = false;
            released  = false;
            isPaused  = false;

            pickedUp       = false;
            pickUpPosition = Vector3.zero;
            pickUpRotation = Quaternion.identity;

            // Call StartInteraction on the InteractionObject
            interactionObject.StartInteraction(effector.bone);
            if (interactionTarget != null)
            {
                interactionTarget.RotateTo(effector.bone.position);
            }
        }
        // Start interaction
        public void Start(InteractionObject interactionObject, string tag, float fadeInTime, bool interrupt)
        {
            // If not in interaction, set effector positions to their bones
            if (!inInteraction) {
                effector.position = effector.bone.position;
                effector.rotation = effector.bone.rotation;
            } else if (!interrupt) return;

            // Get the InteractionTarget
            target = interactionObject.GetTarget(effectorType, tag);
            if (target == null) return;
            interactionTarget = target.GetComponent<InteractionTarget>();

            // Start the interaction
            this.interactionObject = interactionObject;
            if (OnStart != null) OnStart(effectorType, interactionObject);

            // Posing the hand/foot
            if (poser != null) {
                if (poser.poseRoot == null) poser.weight = 0f;

                if (interactionTarget != null) poser.poseRoot = target.transform;
                else poser.poseRoot = null;

                poser.AutoMapping();
            }

            // Reset internal values
            timer = 0f;
            weight = 0f;
            fadeInSpeed = fadeInTime > 0f? 1f / fadeInTime: 1000f;
            length = interactionObject.length;

            triggered = false;
            released = false;
            isPaused = false;

            pickedUp = false;
            pickUpPosition = Vector3.zero;
            pickUpRotation = Quaternion.identity;

            // Call StartInteraction on the InteractionObject
            interactionObject.StartInteraction(effector.bone);
            if (interactionTarget != null) interactionTarget.RotateTo(effector.bone.position);
        }