Skip to content

Instantly share code, notes, and snippets.

@BanksySan
Last active September 21, 2020 11:42
Show Gist options
  • Save BanksySan/eccde0d792008e6354e4d3832a3e61f1 to your computer and use it in GitHub Desktop.
Save BanksySan/eccde0d792008e6354e4d3832a3e61f1 to your computer and use it in GitHub Desktop.
Enabling animation of Cinemachine target group weights.
using Cinemachine;
using UnityEngine;
[ExecuteAlways]
[RequireComponent(typeof(CinemachineTargetGroup))]
public class TargetGroupTransition : MonoBehaviour
{
[Range(0, 1)] public float Blend = 1;
private CinemachineTargetGroup _targetGroup;
private void Start()
{
_targetGroup = GetComponent<CinemachineTargetGroup>();
}
private void LateUpdate()
{
_targetGroup.m_Targets[1].weight = Blend;
_targetGroup.m_Targets[0].weight = 1 - Blend;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment