Ejemplo n.º 1
0
        void Update()
        {
            if (_currentProfile == null)
            {
                return;
            }

            var locationOffset = new Vector3(
                GetNoise(0, _currentProfile.shakeSpeed) * _currentProfile.xMovement,
                GetNoise(1, _currentProfile.shakeSpeed) * _currentProfile.yMovement,
                0
                );

            locationOffset *= _trauma;
            var myTransform = transform;

            myTransform.position = _startPosition + locationOffset;

            var zRotationOffset = GetNoise(10, _currentProfile.shakeSpeed) * _currentProfile.zRotation;

            zRotationOffset          *= (float)Math.Pow(_trauma, 2);
            myTransform.localRotation = Quaternion.Euler(_startRotation.eulerAngles.x, _startRotation.eulerAngles.y, zRotationOffset);

            _trauma -= (Time.deltaTime / _currentProfile.duration);
            if (_trauma <= 0)
            {
                _currentProfile           = null;
                myTransform.position      = _startPosition;
                myTransform.localRotation = _startRotation;
            }
        }
Ejemplo n.º 2
0
        public void Shake(CameraShakeProfile profile = null)
        {
            if (profile == null)
            {
                profile = cameraShakeProfile;
            }

            if (profile == null)
            {
                Debug.Log("Profile is null");
                return;
            }

            _currentProfile = profile;
            _trauma         = 1;
        }