Example #1
0
        public void FixedUpdate()
        {
            if (rotationState == ERotationStates.Neutral)
            {
                return;
            }

            switch (rotationState)
            {
            case ERotationStates.RotatingToNeutral:
                if (currentRotationAngle < 0)
                {
                    currentRotationAngle += degPerUpdate;
                }
                else if (currentRotationAngle > 0)
                {
                    currentRotationAngle -= degPerUpdate;
                }

                if (Math.Abs(currentRotationAngle) <= degPerUpdate)
                {
                    currentRotationAngle = 0.0f;
                    rotationState        = ERotationStates.Neutral;
                    currentRotationState = rotationState.ToString();
                }
                break;

            case ERotationStates.RotatingToMin:
                currentRotationAngle -= degPerUpdate;
                if (currentRotationAngle < minRotateAngle)
                {
                    currentRotationAngle = minRotateAngle;
                    rotationState        = ERotationStates.MinRotation;
                    currentRotationState = rotationState.ToString();
                }
                break;

            case ERotationStates.RotatingToMax:
                currentRotationAngle += degPerUpdate;
                if (currentRotationAngle > maxRotateAngle)
                {
                    currentRotationAngle = maxRotateAngle;
                    rotationState        = ERotationStates.MaxRotation;
                    currentRotationState = rotationState.ToString();
                }
                break;
            }

            rotationTarget.transform.localEulerAngles = new Vector3(currentRotationAngle, 0, 0);
        }
Example #2
0
 public void RotateToMax()
 {
     rotationState        = ERotationStates.RotatingToMax;
     currentRotationState = rotationState.ToString();
 }
Example #3
0
 public void RotateToNeutral()
 {
     rotationState        = ERotationStates.RotatingToNeutral;
     currentRotationState = rotationState.ToString();
 }
        public void FixedUpdate()
        {
            if (rotationState == ERotationStates.Neutral)
                return;

            switch (rotationState)
            {
                case ERotationStates.RotatingToNeutral:
                    if (currentRotationAngle < 0)
                        currentRotationAngle += degPerUpdate;
                    else if (currentRotationAngle > 0)
                        currentRotationAngle -= degPerUpdate;

                    if (Math.Abs(currentRotationAngle) <= degPerUpdate)
                    {
                        currentRotationAngle = 0.0f;
                        rotationState = ERotationStates.Neutral;
                        currentRotationState = rotationState.ToString();
                    }
                    break;

                case ERotationStates.RotatingToMin:
                    currentRotationAngle -= degPerUpdate;
                    if (currentRotationAngle < minRotateAngle)
                    {
                        currentRotationAngle = minRotateAngle;
                        rotationState = ERotationStates.MinRotation;
                        currentRotationState = rotationState.ToString();
                    }
                    break;

                case ERotationStates.RotatingToMax:
                    currentRotationAngle += degPerUpdate;
                    if (currentRotationAngle > maxRotateAngle)
                    {
                        currentRotationAngle = maxRotateAngle;
                        rotationState = ERotationStates.MaxRotation;
                        currentRotationState = rotationState.ToString();
                    }
                    break;
            }

            rotationTarget.transform.localEulerAngles = new Vector3(currentRotationAngle, 0, 0);
        }
 public void RotateToNeutral()
 {
     rotationState = ERotationStates.RotatingToNeutral;
     currentRotationState = rotationState.ToString();
 }
 public void RotateToMin()
 {
     rotationState = ERotationStates.RotatingToMin;
     currentRotationState = rotationState.ToString();
 }