Пример #1
0
        // OnStateExit is called when a transition ends and the state machine finishes evaluating this state
        override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
        {
            Debug.Log("SampoStart OnStateExit called.");
            Sampo _sampo = FindObjectOfType <Sampo>();

            _sampo.ChangeState(Sampo.SampoStateType.Idle);
        }
Пример #2
0
        // Update is called once per frame
        void Update()
        {
            if (_rotate)
            {
                if (_rotationSpeedZ != _targetSpeed)   // Only this condition is needed, because when _rotationSpeedZ reaches a negative value, _rotate is set to false.
                {
                    if (_accelerateOrDecelerate == AccelerateOrDecelerate.Accelerate)
                    {
                        _rotationSpeedZ += Time.deltaTime * _accelerationMultiplier;
                        if (_rotationSpeedZ > _targetSpeed)
                        {
                            _accelerateOrDecelerate = AccelerateOrDecelerate.Decelerate;
                            _rotationSpeedZ         = _targetSpeed;
                            //_sampo.ChangeState(Sampo.SampoStateType.Generate);
                        }
                    }
                    else
                    {
                        _rotationSpeedZ -= Time.deltaTime * _accelerationMultiplier;
                        if (_rotationSpeedZ < 0f)
                        {
                            _accelerateOrDecelerate = AccelerateOrDecelerate.Accelerate;
                            _rotationSpeedZ         = 0f;
                            _rotate = false;
                            if (_sampo._sampoState != Sampo.SampoStateType.Start)
                            {
                                _sampo.ChangeState(Sampo.SampoStateType.Idle);
                            }
                        }
                    }
                }

                if (_rotateRight)
                {
                    transform.Rotate(new Vector3(0f, 0f, _rotationSpeedZ));
                }
                else
                {
                    transform.Rotate(new Vector3(0f, 0f, -_rotationSpeedZ));
                }
            }
        }