Unity

내일배움캠프 18일차 TIL - 시네머신 DollyTrack 찍먹 해보기

Potatopotatopotato 2023. 8. 25. 21:30

시네머신 DollyTrackCart를 사용하여 가상 카메라를 지정된 경로로 움직이게 할 수 있다

가상 카메라 Body 속성의 Path안에 DollyTrack을 끌어서 넣고 Follow에 DollyCart를 넣은 후

Body -> Auto Dolly -> Enabled 체크박스로 시작하자마자 자동으로 움직이게 하거나

아래의 스크립트로 움직이게 할 수 있다

 

using UnityEngine;
using Cinemachine;

public class DollyTutorial : MonoBehaviour
{
    private void Start()
    {
        CinemachineTrackedDolly dollyCamera = GetComponent<CinemachineVirtualCamera>().GetCinemachineComponent<CinemachineTrackedDolly>();

        dollyCamera.m_AutoDolly.m_Enabled = true;
    }
}

GetComponent로 게임 오브젝트에 붙어있는 컴포넌트까진 가져올수있지만

시네머신 컴포넌트안에 있는 컴포넌트를 가져오려면 GetCinemachineComponent를 사용해야한다

 

가져온 후 m_AutoDolly 속성의 m_Enabled를 true로 하면 움직이게 할 수 있다

 

카트의 Speed 속성도 잊지말자 기본 값이 0으로 되어있어서 안움직인다