コード例 #1
0
        private void FixedUpdate()
        {
            // Calculate oscillator position
            float l_pos = _oscillator.Oscillate(Time.fixedDeltaTime);
            // Calculate increment to translate
            float l_increment = l_pos * _movementSemiLength - _sawPosition_0;

            // Translate
            transform.Translate(l_increment, 0.0f, 0.0f, Space.Self);
            // Assign increment to the platform position 0 for next frame
            _sawPosition_0 += l_increment;
        }
コード例 #2
0
        private void FixedUpdate()
        {
            // Calculate oscillator position
            float l_pos = _oscillator.Oscillate(Time.fixedDeltaTime);
            // Calculate increment to translate
            float l_increment = l_pos * _movementSemiLength - _platformPosition_0;

            // Translate
            transform.Translate(
                l_increment * Mathf.Cos(_platformDirection * Mathf.Deg2Rad),
                l_increment * Mathf.Sin(_platformDirection * Mathf.Deg2Rad),
                0.0f);

            // Assign increment to the platform position 0 for next frame
            _platformPosition_0 += l_increment;
        }
コード例 #3
0
ファイル: CrystalGem.cs プロジェクト: aitornalla/TFM_Aitor_TT
        private void Update()
        {
            if (!_isVisible || _isDestroying)
            {
                return;
            }

            // Calculate oscillator position
            float l_pos = _oscillator.Oscillate(Time.deltaTime);
            // Calculate increment to translate
            float l_increment = l_pos * _movementSemiLength - _gemPosition_0;

            // Translate
            transform.Translate(0.0f, l_increment, 0.0f, Space.Self);
            // Assign increment to the platform position 0 for next frame
            _gemPosition_0 += l_increment;
        }
コード例 #4
0
        private void FixedUpdate()
        {
            // Calculate oscillator position
            float l_pos = _oscillator.Oscillate(Time.fixedDeltaTime);
            // Calculate percentage within angle limits
            float l_percent = Mathf.Abs(l_pos - (-1.0f)) / 2.0f;

            // Calculate new angle
            _angleForce = _angleLimit1 - (_angleLimit1 - _angleLimit2) * l_percent;
            // Calculate increment to rotate
            float l_increment = _angleForce - _angle_0;

            // Rotate arrow
            _arrowChild.Rotate(0.0f, 0.0f, l_increment);

            //Debug.Log("Delta: " + Time.fixedDeltaTime + " | Angle: " + l_angle + " | Angle_0: " + _angle_0 + " | Increment: " + l_increment);

            // Assign current angle to angle 0 for next update
            _angle_0 = _angleForce;
        }
コード例 #5
0
 // Update is called once per frame
 private void Update()
 {
     if (_isTimeTrial && _stopwatch.IsRunning)
     {
         // Show elapsed time
         _timeTrialText.text =
             _stopwatch.Elapsed.Minutes.ToString("D2") + ":" +
             _stopwatch.Elapsed.Seconds.ToString("D2") + ":" +
             _stopwatch.Elapsed.Milliseconds.ToString("D3");
     }
     else
     {
         // Calculate oscillator position
         float l_pos = _oscillator.Oscillate(Time.deltaTime);
         // Calculate increment to translate
         float l_increment = l_pos * _movementSemiLength - _gemPosition_0;
         // Translate
         transform.Translate(0.0f, l_increment, 0.0f, Space.Self);
         // Assign increment to the platform position 0 for next frame
         _gemPosition_0 += l_increment;
     }
 }
コード例 #6
0
        private void FixedUpdate()
        {
            // Calculate oscillator position
            float l_pos = _oscillator.Oscillate(Time.fixedDeltaTime);
            // Calculate percentage within angle limits
            float l_percent = Mathf.Abs(l_pos - (-1.0f)) / 2.0f;

            // Calculate new angle
            _angle = _angleLimit1 - (_angleLimit1 - _angleLimit2) * l_percent;
            // Calculate increment to rotate
            float l_increment = _angle - _angle_0;

            // Play sound when spike is in the middle
            if (l_increment > 0.0f)
            {
                float l_midAngle = (_angleLimit1 + _angleLimit2) / 2.0f;

                if (_angle > l_midAngle && _angle_0 < l_midAngle)
                {
                    _audioSource.Play();
                }
            }
            else
            {
                float l_midAngle = (_angleLimit1 + _angleLimit2) / 2.0f;

                if (_angle < l_midAngle && _angle_0 > l_midAngle)
                {
                    _audioSource.Play();
                }
            }
            // Rotate arrow
            transform.RotateAround(_nut.transform.position, Vector3.forward, l_increment);
            _ropechain.transform.RotateAround(_nut.transform.position, Vector3.forward, l_increment);
            // Assign current angle to angle 0 for next update
            _angle_0 = _angle;
        }