I am trying to change the tracking object offset of the middle rig in the freelook cinemachine camera from script, but I can’t find anywhere in the docs a way to access this property. Does anyone here knows how to access this property or can point me in the right direction?
Well just in case that someone else need this as I did, here is how to do it:
using Cinemachine;// Add Cinemachine namespace
You have to create these variables, name them however you want:
GameObject camObj;//This is your camera with the free look component on it
CinemachineFreeLook freeLook;// this reference the free look component in your camera
CinemachineComposer comp;//I named this variable comp for “Composer”, you can name it however you like. This is the cinemachine component with all the aiming stuff on it
comp.m_TrackedObjectOffset.y = “your value here”;// This is how you get to “Tracked Object Offset” of the rig as well as any other property in the rigs.
@JacquesJ Changes to TrackedObjectOffset are instantaneous, while camera movement as a result of target movement is subject to damping. So you can either make a gradual change to the offset, or you can use an invisible child object as your target, placed at the desired offset, and just reposition it. If vcam has damping, it will move gradually.