您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
62 行
1.6 KiB
62 行
1.6 KiB
using System;
|
|
using Cinemachine;
|
|
using UnityEngine;
|
|
|
|
namespace BoatAttack
|
|
{
|
|
public class ReplayCamera : MonoBehaviour
|
|
{
|
|
public static ReplayCamera Instance;
|
|
private static bool _spectatorEnabled;
|
|
private static BoatData _focusedBoat;
|
|
private Transform _focusPoint;
|
|
public CinemachineVirtualCamera droneCamera;
|
|
//public CinemachineVirtualCamera[] levelCameras;
|
|
public CinemachineClearShot clearShot;
|
|
|
|
private void OnEnable()
|
|
{
|
|
Instance = this;
|
|
}
|
|
|
|
private void LateUpdate()
|
|
{
|
|
if (_spectatorEnabled && _focusedBoat == null)
|
|
{
|
|
_focusedBoat = RaceManager.RaceData.boats[0];
|
|
_focusPoint = _focusedBoat.BoatObject.transform;
|
|
SetReplayTarget(_focusPoint);
|
|
}
|
|
}
|
|
|
|
public void EnableSpectatorMode()
|
|
{
|
|
_spectatorEnabled = true;
|
|
//droneCamera.Priority = 100;
|
|
}
|
|
|
|
public void DisableSpectatorMode()
|
|
{
|
|
droneCamera.Priority = -100;
|
|
}
|
|
|
|
private void SetReplayTarget(GameObject go)
|
|
{
|
|
SetReplayTarget(go.transform);
|
|
}
|
|
|
|
private void SetReplayTarget(Transform target)
|
|
{
|
|
_focusPoint = target;
|
|
|
|
if (clearShot)
|
|
{
|
|
clearShot.Priority = 100;
|
|
clearShot.LookAt = _focusPoint;
|
|
}
|
|
|
|
droneCamera.Follow = _focusPoint;
|
|
droneCamera.LookAt = _focusPoint;
|
|
}
|
|
}
|
|
}
|