Пример #1
0
        /// <inheritdoc />
        protected override float CalculateValue(DriveAxis.Axis axis, FloatRange limits)
        {
            if (!isActiveAndEnabled)
            {
                return(0f);
            }

            float result = 0f;

            switch (axis)
            {
            case DriveAxis.Axis.XAxis:
                result = joint.transform.localPosition.x;
                break;

            case DriveAxis.Axis.YAxis:
                result = joint.transform.localPosition.y;
                break;

            case DriveAxis.Axis.ZAxis:
                result = joint.transform.localPosition.z;
                break;
            }
            return(Mathf.Clamp(result, limits.minimum, limits.maximum));
        }
        public override Vector3 CalculateDriveAxis(DriveAxis.Axis driveAxis)
        {
            Vector3 axisDirection = base.CalculateDriveAxis(driveAxis);

            Joint.axis = axisDirection * -1f;
            return(axisDirection);
        }
Пример #3
0
        public override Vector3 CalculateDriveAxis(DriveAxis.Axis driveAxis)
        {
            PositionClamper.XBounds = driveAxis == DriveAxis.Axis.XAxis ? DriveLimits : default;
            PositionClamper.YBounds = driveAxis == DriveAxis.Axis.YAxis ? DriveLimits : default;
            PositionClamper.ZBounds = driveAxis == DriveAxis.Axis.ZAxis ? DriveLimits : default;

            return(-base.CalculateDriveAxis(driveAxis));
        }
Пример #4
0
        /// <inheritdoc />
        protected override float CalculateValue(DriveAxis.Axis driveAxis, FloatRange limits)
        {
            if (!isActiveAndEnabled)
            {
                return(0f);
            }

            return(Mathf.Clamp(pseudoRotation, limits.minimum, limits.maximum));
        }
 public override Vector3 CalculateDriveAxis(DriveAxis.Axis driveAxis)
 {
     Joint.xMotion        = driveAxis == DriveAxis.Axis.XAxis ? ConfigurableJointMotion.Limited : ConfigurableJointMotion.Locked;
     Joint.yMotion        = driveAxis == DriveAxis.Axis.YAxis ? ConfigurableJointMotion.Limited : ConfigurableJointMotion.Locked;
     Joint.zMotion        = driveAxis == DriveAxis.Axis.ZAxis ? ConfigurableJointMotion.Limited : ConfigurableJointMotion.Locked;
     Joint.angularXMotion = ConfigurableJointMotion.Locked;
     Joint.angularYMotion = ConfigurableJointMotion.Locked;
     Joint.angularZMotion = ConfigurableJointMotion.Locked;
     return(base.CalculateDriveAxis(driveAxis));
 }
        /// <inheritdoc />
        public override Vector3 CalculateDriveAxis(DriveAxis.Axis driveAxis)
        {
            if (!isActiveAndEnabled)
            {
                return(Vector3.zero);
            }

            Vector3 axisDirection = base.CalculateDriveAxis(driveAxis);

            joint.axis = axisDirection * -1f;
            return(axisDirection);
        }
Пример #7
0
        /// <inheritdoc />
        public override Vector3 CalculateDriveAxis(DriveAxis.Axis driveAxis)
        {
            if (!isActiveAndEnabled)
            {
                return(Vector3.zero);
            }

            joint.xMotion        = (driveAxis == DriveAxis.Axis.XAxis ? ConfigurableJointMotion.Limited : ConfigurableJointMotion.Locked);
            joint.yMotion        = (driveAxis == DriveAxis.Axis.YAxis ? ConfigurableJointMotion.Limited : ConfigurableJointMotion.Locked);
            joint.zMotion        = (driveAxis == DriveAxis.Axis.ZAxis ? ConfigurableJointMotion.Limited : ConfigurableJointMotion.Locked);
            joint.angularXMotion = ConfigurableJointMotion.Locked;
            joint.angularYMotion = ConfigurableJointMotion.Locked;
            joint.angularZMotion = ConfigurableJointMotion.Locked;
            return(base.CalculateDriveAxis(driveAxis));
        }
        public override Vector3 CalculateDriveAxis(DriveAxis.Axis driveAxis)
        {
            Vector3 axisDirection = base.CalculateDriveAxis(driveAxis);
            switch (driveAxis)
            {
                case DriveAxis.Axis.XAxis:
                    RotationModifier.FollowOnAxis = Vector3State.XOnly;
                    break;
                case DriveAxis.Axis.YAxis:
                    RotationModifier.FollowOnAxis = Vector3State.YOnly;
                    break;
                case DriveAxis.Axis.ZAxis:
                    RotationModifier.FollowOnAxis = Vector3State.ZOnly;
                    break;
            }

            return axisDirection;
        }
Пример #9
0
        protected override float CalculateValue(DriveAxis.Axis axis, FloatRange limits)
        {
            float result = 0f;

            switch (axis)
            {
            case DriveAxis.Axis.XAxis:
                result = GetDriveTransform().localPosition.x;
                break;

            case DriveAxis.Axis.YAxis:
                result = GetDriveTransform().localPosition.y;
                break;

            case DriveAxis.Axis.ZAxis:
                result = GetDriveTransform().localPosition.z;
                break;
            }
            return(Mathf.Clamp(result, limits.minimum, limits.maximum));
        }
Пример #10
0
 /// <summary>
 /// Calculates the axis to use for the given <see cref="DriveAxis.Axis"/>.
 /// </summary>
 /// <param name="driveAxis">The new value.</param>
 protected virtual void CalculateDriveAxis(DriveAxis.Axis driveAxis)
 {
     Drive.CalculateDriveAxis(driveAxis);
 }
Пример #11
0
 /// <inheritdoc />
 public override Vector3 CalculateDriveAxis(DriveAxis.Axis driveAxis)
 {
     if (!this.IsValidState())
     {
         return(default);
Пример #12
0
 /// <summary>
 /// Calculates the current value of the control.
 /// </summary>
 /// <param name="axis">The axis the drive is operating on.</param>
 /// <param name="limits">The limits of the drive.</param>
 /// <returns>The calculated value.</returns>
 protected abstract float CalculateValue(DriveAxis.Axis axis, FloatRange limits);
Пример #13
0
 /// <summary>
 /// Calculates the axis to drive the control on.
 /// </summary>
 /// <param name="driveAxis">The desired world axis.</param>
 /// <returns>The direction of the drive axis.</returns>
 public virtual Vector3 CalculateDriveAxis(DriveAxis.Axis driveAxis)
 {
     return(driveAxis.GetAxisDirection(true));
 }
 /// <inheritdoc />
 protected override float CalculateValue(DriveAxis.Axis axis, FloatRange limits)
 {
     if (!this.IsValidState())
     {
         return(default);
Пример #15
0
 protected override float CalculateValue(DriveAxis.Axis driveAxis, FloatRange limits)
 {
     return(Mathf.Clamp(currentPseudoRotation, limits.minimum, limits.maximum));
 }