Beispiel #1
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.xform,
            destRot,
            this.interpolation,
            this.speed
        );

        UnityConstraints.MaskOutputRotations(this.xform, this.output);
    }
Beispiel #2
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.xform,
            destRot,
            this.interpolation,
            this.rotationSpeed
        );

        UnityConstraints.MaskOutputRotations(this.xform, this.output);
    }
Beispiel #3
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.xform.rotation = this.target.rotation;
            UnityConstraints.MaskOutputRotations(this.xform, this.output);
        }

        if (this.constrainPosition)
        {
            this.pos = this.xform.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.xform.position = pos;
        }
    }