SPIN BOARDING QUEST: ‘Display Boost’ - Solutions

Quest: Spin Boarding Quest
Challenge: Display Boost

Feel free to share your solutions, ideas and creations below. If you get stuck, you can find some ideas here for completing this challenge.

I’m trying to do this with a slider. So far I’ve got a Boost.cs script with the following code. For testing purposes, I’ve just got ActivateBoost() hooked up to a UI button for now. The slider works properly for the first boost but then doesn’t for subsequent boosts. Gotta put a boolean in there somewhere so that it works properly. :slight_smile:

void Start()
{
    surfaceEffector = Ground.GetComponent<SurfaceEffector2D>();
    slider = boostSlider.GetComponent<Slider>();
}

void Update()
{
    if (isBoosting)
    {
        timeLeft = timeToWait;
        timeLeft -= Time.time;
        slider.value = timeLeft;
        print("The timeleft is " + timeLeft);
        if (timeLeft <= 0)
        {
            timeLeft = 0;
        }
    }
    if (!isBoosting)
    {
        timeLeft = 0;
    }
}

public void ActivateBoost()
{
    isBoosting = true;
    StartCoroutine(TurboBoost());
}

IEnumerator TurboBoost() 
{
    print("BOOSTING");
    surfaceEffector.speed = maxSpeed;
yield return new WaitForSeconds(timeToWait);
    isBoosting = false;
    surfaceEffector.speed = minSpeed;
}

}

Privacy & Terms