// Start interaction public bool 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(false); } } // Get the InteractionTarget target = interactionObject.GetTarget(effectorType, tag); if (target == null) { return(false); } interactionTarget = target.GetComponent <InteractionTarget>(); // Start the interaction this.interactionObject = interactionObject; if (interactionSystem.OnInteractionStart != null) { interactionSystem.OnInteractionStart(effectorType, interactionObject); } interactionObject.OnStartInteraction(interactionSystem); // Cleared triggered events triggered.Clear(); for (int i = 0; i < interactionObject.events.Length; i++) { triggered.Add(false); } // 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(); } // See which InteractionObject.WeightCurve.Types are used //private bool positionWeightUsed, rotationWeightUsed, pullUsed, reachUsed, pushUsed, pushParentUsed, poserUsed; positionWeightUsed = interactionObject.CurveUsed(InteractionObject.WeightCurve.Type.PositionWeight); rotationWeightUsed = interactionObject.CurveUsed(InteractionObject.WeightCurve.Type.RotationWeight); pullUsed = interactionObject.CurveUsed(InteractionObject.WeightCurve.Type.Pull); reachUsed = interactionObject.CurveUsed(InteractionObject.WeightCurve.Type.Reach); pushUsed = interactionObject.CurveUsed(InteractionObject.WeightCurve.Type.Push); pushParentUsed = interactionObject.CurveUsed(InteractionObject.WeightCurve.Type.PushParent); //poserUsed = interactionObject.CurveUsed(InteractionObject.WeightCurve.Type.PoserWeight); StoreDefaults(); // Reset internal values timer = 0f; weight = 0f; fadeInSpeed = fadeInTime > 0f? 1f / fadeInTime: 1000f; length = interactionObject.length; isPaused = false; pickedUp = false; pickUpPosition = Vector3.zero; pickUpRotation = Quaternion.identity; if (interactionTarget != null) { interactionTarget.RotateTo(effector.bone.position); } started = true; return(true); }
// Start interaction public bool 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(false); } } // Get the InteractionTarget target = interactionObject.GetTarget(effectorType, tag); if (target == null) { return(false); } interactionTarget = target.GetComponent <InteractionTarget>(); // Start the interaction this.interactionObject = interactionObject; if (interactionSystem.OnInteractionStart != null) { interactionSystem.OnInteractionStart(effectorType, interactionObject); } // Cleared triggered events triggered.Clear(); for (int i = 0; i < interactionObject.events.Length; i++) { triggered.Add(false); } // 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; isPaused = false; pickedUp = false; pickUpPosition = Vector3.zero; pickUpRotation = Quaternion.identity; if (interactionTarget != null) { interactionTarget.RotateTo(effector.bone.position); } return(true); }