Hello. Want to set via code top/mid/bottom rigs tracked object offset for cinemachine freelookcamera and can not get that fields.
Can enyone tell me how to do that?
Hi @demozbox ,
What you’re looking for is the m_TrackedObjectOffset property of the CinemachineComposer. So for example:
using System.Collections;
using System.Collections.Generic;
using Cinemachine;
using UnityEngine;
[ExecuteInEditMode]
public class TrackedObjectOffsetter : MonoBehaviour
{
private CinemachineComposer topComposer;
private CinemachineComposer middleComposer;
private CinemachineComposer bottomComposer;
public Vector3 topOffset;
public Vector3 middleOffset;
public Vector3 bottomOffset;
void Start()
{
var freelook = GetComponent<CinemachineFreeLook>();
topComposer = freelook.GetRig(0).GetCinemachineComponent<CinemachineComposer>();
middleComposer = freelook.GetRig(1).GetCinemachineComponent<CinemachineComposer>();
bottomComposer = freelook.GetRig(2).GetCinemachineComponent<CinemachineComposer>();
}
// Update is called once per frame
void Update()
{
topComposer.m_TrackedObjectOffset = topOffset;
middleComposer.m_TrackedObjectOffset = middleOffset;
bottomComposer.m_TrackedObjectOffset = bottomOffset;
}
}
2 Likes
Thank you for reply. I’ve been working with composer with virtual camera already , but it was way so different. Now I kinda see the logic. Not obvious actually. Thanks again.