using System.Collections; using System.Collections.Generic; using TMPro; using UnityEngine; public class GameManager : MonoBehaviour { public static float movespeed = 0f; public float acceleration = 5; public float maxspeed = 30f; public Camera came; public float minFov = 50; public float maxFov = 90; public float Distance; 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; came.fieldOfView = minFov + x; float displaySpeed = movespeed * 2; txtSpeed.text = displaySpeed.ToString("n0") + " km/h"; Distance += displaySpeed * Time.deltaTime / 3600; txtDistance.text = Distance.ToString("n2") + " km"; } //// /// seconds distance /// 1 10 /// /// 60 600 /// /// 3600 1 /// /// move fov /// 0 50 /// 10 63.3 /// 15 70 /// /// 30 90 /// /// 30/10 = 3 /// 40/3 = 13.33 /// /// 40/30 * 10 = 13.33; /// }