using System.Collections; using System.Collections.Generic; using DefaultNamespace; using UnityEngine; public class Cart : MonoBehaviour, ICart { public Track track = null; public float u = 0; public float a = 0; public float v = 0.5f; public float dt = 0.01f; // Update is called once per frame private void Update() { if (track == null) { return; } v -= a * Time.deltaTime * dt; u += v * Time.deltaTime; u = track.GetPositionOnTrack(u, out var pos, out var rot, out a); transform.position = pos; transform.rotation = rot; } public void setPositionOnTrack() { track.GetPositionOnTrack(u, out var pos, out var rot, out a); transform.position = pos; transform.rotation = rot; } public float getU() { return u; } public Track getTrack() { return track; } }