Stopping a function in a script when i recall it.

(First of all, sorry if my english is bad)
So i have this async function for when i pickup an item, it activate a GameObject, then wait for 3 seconds and deactivate it.
But if i pickup multiple items during those 3 seconds, it stacks the script and force it to deactivate my object.
Any solution to just stop the function when i reuse it ?

async void TriggerPickupPopUp(string ItemName, Sprite itemSprite)
{

    pickupAlert.SetActive(true);

    pickupName.text = ItemName;

    pickupImage.sprite = itemSprite;

    await Task.Delay(3000);

    pickupAlert.SetActive(false);

   
}

Thanks for your help.

Don’t use a coroutine or async thing… this is just a cooldown timer.

Cooldown timers, gun bullet intervals, shot spacing, rate of fire:

GunHeat (gunheat) spawning shooting rate of fire:

i tweaked it a bit but it works now, and i find this easier than using async functions, but i guess both works well.

Will this be much better than using the timer mentionned above ? If yes i might start to look into it.

It’s up to you and your project! glad it worked!