Adding CameraShake component in runtime

Hi,

I can’t find a way to add Noise type e.g. 6DShake or Handheld_Mild and stuff following below script step,
Any suggestions?

CinemachineBrain brain = FindObjectOfType<CinemachineBrain>();
                if (brain)
                {
                    ICinemachineCamera vCam = brain.ActiveVirtualCamera;
                    if (vCam.IsValid)
                    {
                        vCam_Main = vCam.VirtualCameraGameObject;
                    }
                }
               
            }
            if (vCam_Main != null)
            {
                CinemachineVirtualCamera virtualCamera = vCam_Main.GetComponent<CinemachineVirtualCamera>();
                CinemachineBasicMultiChannelPerlin noiseProfile = virtualCamera.GetCinemachineComponent<CinemachineBasicMultiChannelPerlin>();

                if (noiseProfile == null)
                {
                    CinemachineBasicMultiChannelPerlin noiseProfileAdded = virtualCamera.AddCinemachineComponent<CinemachineBasicMultiChannelPerlin>();
                    noiseProfileAdded.m_NoiseProfile = new NoiseSettings();

Hi

You could have a public NoiseSettings noise parameter for your script, and then you can pass the noiseprofile from the editor.

Is there any way to create that in runtime? (If none, then I can reference it from e.g. GameManager but this is a but tedious to be exposed and set in the editor for my structure!

You could create them at runtime. However, I would highly suggest you to use our UI to create a noiseProfile, because this way you have visual feedback on how the noise is going to look like. Then pass this created noiseProfile to your script.

Otherwise, you can do something like this in script to create one:

NoiseSettings noise = new NoiseSettings
{
    OrientationNoise = new[]
    {
        new NoiseSettings.TransformNoiseParams
        {
            X = new NoiseSettings.NoiseParams
            {
                Amplitude = 1,
                Constant = false,
                Frequency = 1,
            },
            Y = new NoiseSettings.NoiseParams
            {
                Amplitude = 1,
                Constant = false,
                Frequency = 2,
            },
            Z = new NoiseSettings.NoiseParams
            {
                Amplitude = 2,
                Constant = false,
                Frequency = 1,
            },
        }
    },
    PositionNoise = new[]
    {
        new NoiseSettings.TransformNoiseParams
        {
            X = new NoiseSettings.NoiseParams
            {
                Amplitude = 1,
                Constant = true,
                Frequency = 1,
            },
            Y = new NoiseSettings.NoiseParams
            {
                Amplitude = 6,
                Constant = false,
                Frequency = 1,
            },
            Z = new NoiseSettings.NoiseParams
            {
                Amplitude = 1,
                Constant = false,
                Frequency = 4,
            },
        }
    },
};