Code:
void OnTriggerEnter(Collider other) {
if (other.gameObject.tag == "PickUp") {
SetRandomPickupPosition();
count++;
SetCountText();
var particleClone = Instantiate(particle, pickup.transform.position, pickup.transform.rotation);
Action a = () => Destroy(particleClone);
DelayedAction(2.0f, a);
}
}
IEnumerator DelayedAction(float delay, Action action) {
yield return new WaitForSeconds(delay);
action.Invoke();
}
Code:
void OnTriggerEnter(Collider other) {
if (other.gameObject.tag == "PickUp") {
SetRandomPickupPosition();
count++;
SetCountText();
var particleClone = Instantiate(particle, pickup.transform.position, pickup.transform.rotation);
Destroy(particleClone);
}
}
IEnumerator DelayedAction(float delay, Action action) {
yield return new WaitForSeconds(delay);
action.Invoke();
}






