gold_sprint_lpr/Assets/Scripts/GameScene/HUDProgress.cs

32 lines
811 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class HUDProgress : MonoBehaviour {
public GameObject start;
public GameObject end;
public BikeManager bikeManager;
private Transform tstart;
private Transform tend;
private GameObject progress;
// Use this for initialization
void Start () {
tstart = start.GetComponent<Transform>();
tend = end.GetComponent<Transform>();
progress = new GameObject("Progress");
progress.transform.parent = tstart;
progress.transform.localPosition = new Vector3(0, 0, 0);
}
// Update is called once per frame
void Update () {
float p = bikeManager.GetProgress();
progress.transform.position = tstart.position * (1 - p) + tend.position * p;
}
}