Hello, I want to create a progress bar showing player movement from start to finish. with a check point What should I do in the middle?
Now I can get the player to the last point but I want to add checkpoints, what should I do?
public class Progressnar2 : MonoBehaviour
{
public Transform Player;
public Transform End;
public Slider slider;
float maxDistance;
void Start()
{
maxDistance = getDistance();
}
// Update is called once per frame
void Update()
{
if (Player.position.z <= maxDistance && Player.position.z <= End.position.z)
{
float distance = 1 - (getDistance() / maxDistance) ;
setProgress(distance);
}
}
float getDistance()
{
return Vector3.Distance(Player.position,End.position );
}
void setProgress(float p)
{
slider.value = p;
}
}