I have added progress bar which is working fine for straight path. but in curve path as shown in figure the progress bar starts moving backwards due to decrease in z position of car.
I have added many check point to calculate the distance between them and added them.
but issue with current position. how to manage current position of car and move the progress bar.
public Transform LevelEndCheckpoint;
public Slider ProgressSlider;
private float totalDistance,current_position,playerPosition;
// Use this for initialization
void OnEnable () {
playerPosition = this.transform.position.z;
//totalDistance = LevelEndCheckpoint.transform.position.z - playerPosition;
for (int i = 0; i < p_Length; i++) {
totalDistance += Vector3.Distance( AllPoints [i + 1].position , AllPoints *.position);*
-
}*
-
ProgressSlider.maxValue = -totalDistance;*
-
ProgressSlider.minValue = -playerPosition;*
- }*
- void Update () {*
-
playerPosition = -this.transform.position.z;*
-
ProgressSlider.value = playerPosition;*
- }*
[121792-screenshot-10.png|121792]*
[121793-screenshot-11.jpg|121793]*
,