How to delete a drop item after a certain amount of time

ymo

Member
How to delete a drop item after a certain amount of time
Is it better to destroy the drop item with the Invoke method?
Or should I use the UCC object pool?

C#:
    void Start()
    {
    Invoke("InvokeDropItemDestroy", 10);
    }

    void InvokeDropItemDestroy()
    {
        Destroy(this.gameObject);
    }
 
If you are using our ItemPickup solution you should use the Object Pool to destroy the pickup.
When you aren't sure if an object is pooled you can use:
Code:
if (ObjectPool.IsPooledObject(gameObject)) {
    ObjectPool.Destroy(gameObject);
}

For the ItemPickup specifically if you have reference to the ItemPickup component you may use:
Code:
itemPickup.Deactivate();
This will internally remove the itempickup.

Also you can use the Scheduler to invoke a function after a certain delay instead of using the "Invoke("functionName",delay)" function
 
  • Like
Reactions: ymo
Top