コード例 #1
0
 /// <summary>
 /// Runs when the noTarget mode is set to ReturnToDefault
 /// </summary>
 protected override void NoTargetDefault()
 {
     UnityConstraints.InterpolateLocalRotationTo
     (
         this.transform,
         Quaternion.identity,
         this.interpolation,
         this.speed
     );
 }
コード例 #2
0
        /// <summary>
        /// Runs when the constraint is active or when the noTarget mode is set to
        /// ReturnToDefault
        /// </summary>
        private void OutputTowards(Quaternion destRot)
        {
            UnityConstraints.InterpolateRotationTo
            (
                this.transform,
                destRot,
                this.interpolation,
                this.speed
            );

            UnityConstraints.MaskOutputRotations(this.transform, this.output);
        }
コード例 #3
0
        /// <summary>
        /// Runs when the constraint is active or when the noTarget mode is set to
        /// ReturnToDefault
        /// </summary>
        private void OutputRotationTowards(Quaternion destRot)
        {
            // Faster exit if nothing to do.
            if (!this.constrainRotation)
            {
                return;
            }

            UnityConstraints.InterpolateRotationTo
            (
                this.transform,
                destRot,
                this.interpolation,
                this.rotationSpeed
            );

            UnityConstraints.MaskOutputRotations(this.transform, this.output);
        }
コード例 #4
0
        /// <summary>
        /// Runs each frame while the constraint is active
        /// </summary>
        protected override void OnConstraintUpdate()
        {
            // Note: Do not run base.OnConstraintUpdate. It is not implimented

            if (this.constrainScale)
            {
                this.SetWorldScale(target);
            }

            if (this.constrainRotation)
            {
                this.transform.rotation = this.target.rotation;
                UnityConstraints.MaskOutputRotations(this.transform, this.output);
            }

            if (this.constrainPosition)
            {
                this.pos = this.transform.position;

                // Output only if wanted
                if (this.outputPosX)
                {
                    this.pos.x = this.target.position.x;
                }
                if (this.outputPosY)
                {
                    this.pos.y = this.target.position.y;
                }
                if (this.outputPosZ)
                {
                    this.pos.z = this.target.position.z;
                }

                this.transform.position = pos;
            }
        }