Last active
September 21, 2020 11:42
-
-
Save BanksySan/eccde0d792008e6354e4d3832a3e61f1 to your computer and use it in GitHub Desktop.
Enabling animation of Cinemachine target group weights.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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