I disabled gamecontroller for 15.9 seconds and controller not awake again.It's for cutscene cam before the race start.
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// Move and rotation camera controller
/// </summary>
public class CameraController :Singleton<CameraController>
{
[SerializeField] List<CameraPreset> CamerasPreset = new List<CameraPreset>(); //Camera presets
[SerializeField] CarController OverrideCar;
private GameObject cam;
int ActivePresetIndex = -1;
public CameraPreset ActivePreset { get; private set; }
CarController TargetCar { get { return OverrideCar?? GameController.PlayerCar; } }
GameController GameController { get { return GameController.Instance; } }
float SqrMinDistance;
int CurrentFrame = 0;
//The target point is calculated from velocity of car.
Vector3 m_TargetPoint;
Vector3 TargetPoint
{
get
{
if (CurrentFrame != Time.frameCount)
{
if (!OverrideCar && GameController == null || TargetCar == null)
{
return transform.position;
}
m_TargetPoint = TargetCar.RB.velocity * ActivePreset.VelocityMultiplier;
m_TargetPoint += TargetCar.transform.position;
CurrentFrame = Time.frameCount;
}
return m_TargetPoint;
}
}
protected override void AwakeSingleton ()
{
CamerasPreset.ForEach (c => c.CameraHolder.SetActive (false));
ActivePresetIndex = GameOptions.ActiveCameraIndex;
UpdateActiveCamera ();
}
private IEnumerator Start ()
{
cam = GameObject.FindGameObjectWithTag("cam");
ActivePreset.EnableRotation = false;
GameController.SetActive(false);
yield return new WaitForSeconds (15.9f);
GameController.SetActive(true);
cam.SetActive(false);
transform.position = TargetPoint;
ActivePreset.CameraHolder.rotation = TargetCar.transform.rotation;
ActivePreset.EnableRotation = true;
}