proto_racer/Assets/Scripts/FovAccelerator.cs

28 lines
590 B
C#
Raw Normal View History

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Assertions;
using UnityEngine.UI;
[RequireComponent(typeof(Camera))]
public class FovAccelerator : MonoBehaviour
{
public float minFov;
public float maxFov;
public CarLogic car;
private Camera _camera;
private void Start()
{
Assert.IsTrue(car != null);
_camera = GetComponent<Camera>();
}
private void Update()
{
_camera.orthographicSize = Mathf.Lerp(minFov, maxFov, car.CurrentAccelerationRatio());
}
}