Posting here too in case the other forum wasn’t right:
Hi.
I’m trying to make a timeline sequence which can change in some situations (the change is decided before the sequence starts playing)
Specifically replace a virtual camera in one of the shots clip.
But I am not able to figure out how to replace my CinemachineShot clip in the Cinemachine track.
I tried to simply apply a different virtual camera by code, it worked but the clip got broken and the virtual camera properties in that shot were not applied. when the timeline plays it ignores the clip altogether as if in that point there is no virtual camera active at all.
Any help about this would be appreciated.
Edit:
this is the code for I tested with:
public static void ReplaceClipCinemachineCamera(this PlayableDirector playableDirector,
string trackName,
string clipName,
GameObject otherVirtualCamera)
{
TimelineAsset timeline = playableDirector.playableAsset as TimelineAsset;
if (timeline == null)
{
return;
}
foreach (var trackAsset in timeline.GetOutputTracks())
{
if (trackAsset.name == trackName)
{
var clipToEdit = trackAsset.GetClips()
.FirstOrDefault(clip => clip.displayName == clipName);
if (clipToEdit == null)
{
continue;
}
var controlPlayableAsset = (clipToEdit.asset as CinemachineShot);
if (controlPlayableAsset == null)
{
return;
}
playableDirector.SetReferenceValue(controlPlayableAsset.VirtualCamera.exposedName, otherVirtualCamera);
}
}
}