using System.Collections; using System.Collections.Generic; using Cinemachine; using TMPro; using UnityEngine; public class GameManager : MonoBehaviour { public static float movespeed = 0f; public float acceleration = 5; public float maxspeed = 30f; public CinemachineVirtualCamera cam; public float minFov = 50; public float maxFov = 90; public float Distance; public float max_shake_ferquency = 2f; public float max_shake_amplitude = 0.08f; public TMP_Text txtSpeed; public TMP_Text txtDistance; public float FovRange => maxFov - minFov; void Start() { } // Update is called once per frame void FixedUpdate() { float input = Input.GetAxis("Vertical"); movespeed += input * acceleration * Time.deltaTime; movespeed = Mathf.Clamp(movespeed, 0, maxspeed); float x = (FovRange / maxspeed) * movespeed; cam.m_Lens.FieldOfView = minFov + x; cam.GetCinemachineComponent().m_FrequencyGain = max_shake_ferquency * movespeed / maxspeed; cam.GetCinemachineComponent().m_AmplitudeGain = max_shake_amplitude * movespeed / maxspeed; float displaySpeed = movespeed * 2; txtSpeed.text = displaySpeed.ToString("n0") + " km/h"; Distance += displaySpeed * Time.deltaTime / 3600; txtDistance.text = Distance.ToString("n2") + " km"; float fontSize = Mathf.Lerp(10f, 15f, movespeed / maxspeed); txtSpeed.fontSize = fontSize; txtDistance.fontSize = fontSize; } }