fgm24/Assets/Scripts/CameraScripts/SetupCinemachine.cs

25 lines
635 B
C#

using Cinemachine;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
public class SetupCinemachine : MonoBehaviour
{
public CinemachineTargetGroup targetbrain;
[SerializeField] private float targetRadius = 3f;
private void OnEnable()
{
GameManager.OnPlayersReady += OnPlayersReady;
}
private void OnPlayersReady(GameObject[] players)
{
var targets = players.Select(x => new CinemachineTargetGroup.Target { target = x.transform, weight = 1, radius = targetRadius }).ToArray();
targetbrain.m_Targets = targets;
}
}