- Home /
Cinemachine FreeLook Camera Shake
Need to shake the third person 'Cinemachine FreeLook' camera for just half a second. I've seen answers for shaking the 'Cinemachine VirtualCamera,' but it doesn't seem to work the same on FreeLook. Can someone point me in the right direction? Thanks.
Answer by stewe02 · May 03, 2020 at 01:26 PM
Hi Mjhurtado1 , I had this problem my self and I just figured out how to do it . This is how I made it :
using System.Collections; using UnityEngine; using Cinemachine; using Cinemachine.Editor; using Cinemachine.Utility;
public class CameraShake : MonoBehaviour { public float amplitudeGain; public float frequemcyGain; public CinemachineFreeLook cmFreeCam; public float shakeDuration;
public void DoShake()
{
StartCoroutine(Shake());
}
public IEnumerator Shake()
{
Noise(amplitudeGain, frequemcyGain);
yield return new WaitForSeconds(shakeDuration);
Noise(0,0);
}
void Noise(float amplitude,float frequency)
{
cmFreeCam.GetRig(0).GetCinemachineComponent<CinemachineBasicMultiChannelPerlin>().m_AmplitudeGain = amplitude;
cmFreeCam.GetRig(1).GetCinemachineComponent<CinemachineBasicMultiChannelPerlin>().m_AmplitudeGain = amplitude;
cmFreeCam.GetRig(2).GetCinemachineComponent<CinemachineBasicMultiChannelPerlin>().m_AmplitudeGain = amplitude;
cmFreeCam.GetRig(0).GetCinemachineComponent<CinemachineBasicMultiChannelPerlin>().m_FrequencyGain = frequency;
cmFreeCam.GetRig(1).GetCinemachineComponent<CinemachineBasicMultiChannelPerlin>().m_FrequencyGain = frequency;
cmFreeCam.GetRig(2).GetCinemachineComponent<CinemachineBasicMultiChannelPerlin>().m_FrequencyGain = frequency;
}
}
Your answer
Follow this Question
Related Questions
How do I make a third person camera toggle that doesn't snap? 0 Answers
Smooth dizzy camera shake. 0 Answers
3rd Person Camera Collision 4 Answers
Cinemachine Noise Messes Up Isometric Z as Y Tilemap 1 Answer
Camera shake 11 Answers