'How to Make power ups reusable in unity's karting microgame?

I'm modifying unity's karting microgame and I wanted to make the speed-pads able to be used more than once because the way they are programmed makes it so that they can only be used up until the MaxTime "x" amount of seconds is reached. The player can even pick up the power-up after the MaxTime is reached but it doesn't do anything... I strongly suggest you download the karting microgame to have a better view of the issue but here is the code for the power-up:

using KartGame.KartSystems;
using UnityEngine;
using UnityEngine.Events;
 

public class ArcadeKartPowerup : MonoBehaviour {


public ArcadeKart.StatPowerup boostStats = new ArcadeKart.StatPowerup
{
    MaxTime = 5f
};

public bool isCoolingDown { get; private set; }
public float lastActivatedTimestamp { get; private set; }

public float cooldown = 5f;

public bool disableGameObjectWhenActivated;
public UnityEvent onPowerupActivated;
public UnityEvent onPowerupFinishCooldown;

private void Awake()
{
    lastActivatedTimestamp = -9999f;
}


private void Update()
{
    if (isCoolingDown)
    {
        if (Time.time - lastActivatedTimestamp > cooldown)
        {
            //finished cooldown!
            isCoolingDown = false;
            onPowerupFinishCooldown.Invoke();
        }

    }
}

private void OnTriggerEnter(Collider other)
{
    if (isCoolingDown) return;

    var rb = other.attachedRigidbody;
    if (rb) {

        var kart = rb.GetComponent<ArcadeKart>();

        if (kart)
        {
            lastActivatedTimestamp = Time.time;
            kart.AddPowerup(this.boostStats);
            onPowerupActivated.Invoke();
            isCoolingDown = true;

            if (disableGameObjectWhenActivated) this.gameObject.SetActive(false);
        }
    }
}


}

I'm did not manage to place the kart code here because it goes over the character limit, but you can easily check it out by downloading the karting microgame in Unity Hub! In this context, the Kart's script serves the function of provinding the stats that can be boosted. The idea that I had that might (or not) work is to make it so that every time the "isCollingDown" returns just add another variable that controls how long the effect lasts to the MaxTime variable, something like "MaxTime = MaxTime + EffectDuration." But I don't know how to implement this... I'm sorry if there is a very obvious answer to this issue but I really don't understand a lot about scripts!



Solution 1:[1]

It actually already has a function build in for what you want to achive so you do not have to code anything.

You see the property disableGameObjectWhenActivated. This one should be set true right now. Just set it false and it will have a cooldown instead of beeing disabled afterwards. Now if you want to get rid of the cooldown I would just set the cooldown to 0.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 At Least Vision