Beispiel #1
0
 public void SetCameraShake(CameraShakeProps shakeProps)
 {
     if (shot.LiveChild != null)
     {
         CinemachineVirtualCamera           cam   = shot.LiveChild as CinemachineVirtualCamera;
         CinemachineBasicMultiChannelPerlin noise = cam.GetCinemachineComponent <CinemachineBasicMultiChannelPerlin> ( );
         if (noise != null)
         {
             noise.m_AmplitudeGain = shakeProps.Amplitude;
             noise.m_FrequencyGain = shakeProps.Frequency;
         }
     }
 }
Beispiel #2
0
        //CinemachineVirtualCamera shakingCamera = null;
        async public void ShakeCamera(CameraShakeProps shakeProps = null)
        {
            CameraShakeProps props = shakeProps == null?this.shakeProps : shakeProps;

            if (shot.LiveChild != null)
            {
                CinemachineVirtualCamera           cam   = shot.LiveChild as CinemachineVirtualCamera;
                CinemachineBasicMultiChannelPerlin noise = cam.GetCinemachineComponent <CinemachineBasicMultiChannelPerlin> ( );
                if (noise != null)
                {
                    noise.m_AmplitudeGain = props.Amplitude;
                    noise.m_FrequencyGain = props.Frequency;
                    await Task.Delay(props.ShakeDuration);

                    noise.m_AmplitudeGain = 0f;
                    noise.m_FrequencyGain = 0f;
                }
            }
        }