Its possible change deadzone from CineMachine by script?

Hi all.

I would like to change deadzone width from my Cinemachine.

How I can get a reference to Cinemachine object type?
It has any property “setter” to change deadzones values?
I’m using in 2D way, to follow my player.

Thanks.

Yes, there is an API for this. See ScriptingExample.cs in the Examples folder for some sample code. You’ll need to do something like this:

        var composer = vcam.GetCinemachineComponent<CinemachineComposer>();
        composer.m_DeadZoneWidth = 0.30f;
        composer.m_DeadZoneHeight = 0.35f;
2 Likes

And if you’re using a vcam with FramingTransposer, it would be

        var composer = vcam.GetCinemachineComponent<CinemachineFramingTransposer>();
        composer.m_DeadZoneWidth = 0.30f;
        composer.m_DeadZoneHeight = 0.35f;
4 Likes

Great Gregory!
It works with CinemachineFramingTransposer.

Thanks a lot!

Glad it’s working. I noticed an error in my post, however. You should be using GetCinemachineComponent<>, not AddCinemachineComponent<>. Both will work, but the first will perform better. I’ve edited my original post to correct it.

Hello!
I would like to do the same with the FreeLook Camera; changing the Dead Zone for the composer in all 3 rigs (top, middle, bottom) by script. Is this possible?
Also, is there a place where we can find all the scripting API for Cinemachine? (I could not find anything online)
Thank you!

Have a look at ScriptingExample.cs, that comes with the Cinemachine example scenes. It will show you what you need to do. There is an API manual that comes with the package - look in the Cinemachine folder in your project.

Thank you kindly!

Hello i would like to reduce the Y Damping while my character is falling, i am having difficult to add a script that does that to my camera, is there any way to add a behavior script to the virtual camera?

Just add it. Have a look at ScriptingExample.cs, that comes with the Cinemachine example scenes. It will give you some clues about how to access fields like damping, inside the vcam’s composer or transposer.

Another (possibly better) option would be to create a second vcam, with settings tuned for falling, and blend to it when the character is falling.

1 Like

It worked thank you for your help and suggestion.

I was able to perform the changes by code, i was also trying to blend between the two cameras, is there a way to trigger the blend without a state driven camera?

Raise the priority of the falling vcam when falling, and lower it when not falling.

1 Like

It worked, thank you!

Anyone know how to do this with a free camera? GetCinemachineComponent doesn’t seem to exist. This may be just been updated or a quirk of using free camera? Regardless I can’t seem to find anywhere else that mentions changeing dead zones in code.

Have a look at the Scripting scene in CinemachineExamples. That should put you on the right path.