playMaker

Author Topic: Cinemachine Support [ECOSYSTEM] [MAY 2020]  (Read 24944 times)

Twood

  • Junior Playmaker
  • **
  • Posts: 76
Re: Cinemachine Support [ECOSYSTEM] [MAY 2020]
« Reply #45 on: January 02, 2022, 04:12:56 PM »
Why no reply? I still need it.
Or it cannot be done? If so, I will use alternative way by myself.

@samsss Your request was a while ago, but I recently made that C# script for myself to change Cinemachine noise levels while using PM.

To use it first make sure you have enabled Basic Perlin Channel Noise on the Noise setting of this Cinemachine camera, then put this script on it.

Assign the camera object where it asks, and it has open settings for 3 different noise levels.

To start a noise level in-game, you use the Call Method action in Playmaker and the CinemachineNoiseAdjust script you just placed as target, and you will see the different noise profiles as method names in a dropdown.

You could also change the values directly with Set Property on the script, but make sure you Call Method any time you want to update the value. In that case you'd probably just one only one set of the variables and one method and can ignore the others.
« Last Edit: January 02, 2022, 04:32:34 PM by Twood »

craigz

  • Beta Group
  • Full Member
  • *
  • Posts: 234
    • Haven Made
Re: Cinemachine Support [ECOSYSTEM] [MAY 2020]
« Reply #46 on: January 18, 2022, 03:11:56 PM »
Thanks for this Twood! :D

Twood

  • Junior Playmaker
  • **
  • Posts: 76
Re: Cinemachine Support [ECOSYSTEM] [MAY 2020]
« Reply #47 on: January 25, 2022, 01:21:52 AM »
No prob. It's probably much better to build it as a playmaker action instead of doing it this way. I will likely be doing that at some point.

Twood

  • Junior Playmaker
  • **
  • Posts: 76
Re: Cinemachine Support [ECOSYSTEM] [MAY 2020]
« Reply #48 on: January 25, 2022, 05:30:47 PM »
Update. I turned cinemachine noise adjustment into a Playmaker action.

Coding is NOT my main thing so let me know if I'm doing anything weird, but it runs fine for me in Unity.

Code: [Select]
using UnityEngine;


namespace HutongGames.PlayMaker.Actions.ecosystem.cinemachine

{
    [ActionCategory("Cinemachine")]
    [Tooltip("Allows you to adjust noise on a Cinemachine camera that has perlin noise enabled.")]


    public class CinemachineNoiseAdjust : FsmStateAction
    {

       
        [CheckForComponent(typeof(Cinemachine.CinemachineVirtualCamera))]
        [RequiredField]
        public Cinemachine.CinemachineVirtualCamera vcam;
        private Cinemachine.CinemachineBasicMultiChannelPerlin noiseChannel;
       

        public FsmFloat Amplitude;

        public FsmFloat Frequency;

        public FsmBool everyFrame;

        private bool goEveryFrame;
        private float goAmplitude;
        private float goFrequency;

         
        public override void OnEnter()

        {
            goAmplitude = Amplitude.Value;
            goFrequency = Frequency.Value;
            goEveryFrame = everyFrame.Value;


            vcam.GetCinemachineComponent<Cinemachine.CinemachineBasicMultiChannelPerlin>().m_AmplitudeGain = goAmplitude;
            vcam.GetCinemachineComponent<Cinemachine.CinemachineBasicMultiChannelPerlin>().m_FrequencyGain = goFrequency;

            if (!goEveryFrame)
            Finish();

        }

        public override void OnUpdate()
        {
            base.OnUpdate();
            if (goEveryFrame == true)
            {
                goAmplitude = Amplitude.Value;
                goFrequency = Frequency.Value;
                goEveryFrame = everyFrame.Value;


                vcam.GetCinemachineComponent<Cinemachine.CinemachineBasicMultiChannelPerlin>().m_AmplitudeGain = goAmplitude;
                vcam.GetCinemachineComponent<Cinemachine.CinemachineBasicMultiChannelPerlin>().m_FrequencyGain = goFrequency;
            }

        }

        public override void Reset()
        {
            Amplitude = null;
            Frequency = null;
            vcam = null;
            noiseChannel = null;
            goFrequency = 0;
            goAmplitude = 0;
            everyFrame = false;
            goEveryFrame = false;

        }

    }
}

pez

  • Playmaker Newbie
  • *
  • Posts: 12
Re: Cinemachine Support [ECOSYSTEM] [MAY 2020]
« Reply #49 on: July 23, 2022, 01:47:21 AM »
Update. I turned cinemachine noise adjustment into a Playmaker action.

Coding is NOT my main thing so let me know if I'm doing anything weird, but it runs fine for me in Unity.

Code: [Select]
using UnityEngine;


namespace HutongGames.PlayMaker.Actions.ecosystem.cinemachine

{
    [ActionCategory("Cinemachine")]
    [Tooltip("Allows you to adjust noise on a Cinemachine camera that has perlin noise enabled.")]


    public class CinemachineNoiseAdjust : FsmStateAction
    {

       
        [CheckForComponent(typeof(Cinemachine.CinemachineVirtualCamera))]
        [RequiredField]
        public Cinemachine.CinemachineVirtualCamera vcam;
        private Cinemachine.CinemachineBasicMultiChannelPerlin noiseChannel;
       

        public FsmFloat Amplitude;

        public FsmFloat Frequency;

        public FsmBool everyFrame;

        private bool goEveryFrame;
        private float goAmplitude;
        private float goFrequency;

         
        public override void OnEnter()

        {
            goAmplitude = Amplitude.Value;
            goFrequency = Frequency.Value;
            goEveryFrame = everyFrame.Value;


            vcam.GetCinemachineComponent<Cinemachine.CinemachineBasicMultiChannelPerlin>().m_AmplitudeGain = goAmplitude;
            vcam.GetCinemachineComponent<Cinemachine.CinemachineBasicMultiChannelPerlin>().m_FrequencyGain = goFrequency;

            if (!goEveryFrame)
            Finish();

        }

        public override void OnUpdate()
        {
            base.OnUpdate();
            if (goEveryFrame == true)
            {
                goAmplitude = Amplitude.Value;
                goFrequency = Frequency.Value;
                goEveryFrame = everyFrame.Value;


                vcam.GetCinemachineComponent<Cinemachine.CinemachineBasicMultiChannelPerlin>().m_AmplitudeGain = goAmplitude;
                vcam.GetCinemachineComponent<Cinemachine.CinemachineBasicMultiChannelPerlin>().m_FrequencyGain = goFrequency;
            }

        }

        public override void Reset()
        {
            Amplitude = null;
            Frequency = null;
            vcam = null;
            noiseChannel = null;
            goFrequency = 0;
            goAmplitude = 0;
            everyFrame = false;
            goEveryFrame = false;

        }

    }
}

Hi Twood

Just came across this thread as control over noise was something I was looking for (want to be able to ramp up & loop noise over having a one off impulse, which is all we have control to do at the moment).

Unfortunately I couldn't use your script or action as they're specifically for Vcams - where as I need it on the FreeLook cam. I tried editing the action to fit but I don't know how you'd go about it to be honest as each of the 'Rigs' in a FreeLook cam has their own noise profiles too.

Let me know if you have any ideas!

Cheers,
Pez


Twood

  • Junior Playmaker
  • **
  • Posts: 76
Re: Cinemachine Support [ECOSYSTEM] [MAY 2020]
« Reply #50 on: July 24, 2022, 07:49:27 PM »

Hi Twood

Just came across this thread as control over noise was something I was looking for (want to be able to ramp up & loop noise over having a one off impulse, which is all we have control to do at the moment).

Unfortunately I couldn't use your script or action as they're specifically for Vcams - where as I need it on the FreeLook cam. I tried editing the action to fit but I don't know how you'd go about it to be honest as each of the 'Rigs' in a FreeLook cam has their own noise profiles too.

Let me know if you have any ideas!

Cheers,
Pez

Fairly busy lately but I'll try to look at it at some point. Sounds like the FreeLook cam is a separate script so it needs a reworking to be able to use that.

And actually it's a little weird, if I don't get back to this in a bit the info you need is : https://forum.unity.com/threads/how-to-change-noise-in-freelook-camara.1087754/

That is how you get a copy of each of vcam hidden in freelook, then you can be able to change noise with some reworking, but basically the same way
« Last Edit: July 25, 2022, 01:32:31 PM by Twood »

pez

  • Playmaker Newbie
  • *
  • Posts: 12
Re: Cinemachine Support [ECOSYSTEM] [MAY 2020]
« Reply #51 on: July 25, 2022, 02:50:19 PM »

Fairly busy lately but I'll try to look at it at some point. Sounds like the FreeLook cam is a separate script so it needs a reworking to be able to use that.

And actually it's a little weird, if I don't get back to this in a bit the info you need is : https://forum.unity.com/threads/how-to-change-noise-in-freelook-camara.1087754/

That is how you get a copy of each of vcam hidden in freelook, then you can be able to change noise with some reworking, but basically the same way


Ok thanks for the info!

I made a sort of makeshift workaround by using 2 impulses together - having one be a build up & then transitioning to the second for a looping rumble. Not the best, but it'll do, so don't worry about trying to make this work just for me!

Cheers,

Twood

  • Junior Playmaker
  • **
  • Posts: 76
Re: Cinemachine Support [ECOSYSTEM] [MAY 2020]
« Reply #52 on: July 25, 2022, 08:08:45 PM »


Ok thanks for the info!

I made a sort of makeshift workaround by using 2 impulses together - having one be a build up & then transitioning to the second for a looping rumble. Not the best, but it'll do, so don't worry about trying to make this work just for me!

Cheers,

Hey everything is makeshift in game development really, if it works, it works! I have an idea that I could just make a "get freelook vcams" action though that could stack before my noise action. I'll throw that together at some point, hopefully.

Lars Steenhoff

  • Beta Group
  • Playmaker Newbie
  • *
  • Posts: 46
Re: Cinemachine Support [ECOSYSTEM] [MAY 2020]
« Reply #53 on: December 21, 2023, 05:40:24 PM »
Cinemachine 3 is out now and has breaking changes.
I Would like to request updated actions for cinemachine 3

https://forum.unity.com/threads/official-cinemachine-3-is-now-available.1524466/#post-9539908