Utilizing Instantiate and Destroy on a "one-use" item

I am currently working on an item that can be picked up from a point and carried around until it is dropped. On drop, it is destroyed.

The carrying around is all fine cause of the standard pickup functionality but I have found issues on the drop step as well as a side feature. This feature is that upon pickup a copy of the pickup is created so that another player can pick up this object (think of it as an endless supply). In both of these instances I have found unique errors that I will break into two instances:

Testing in Unity
On testing in Unity I found that the object successfully duplicates itself, but fails to destroy on drop.

Testing in VRC
On running in VRC the object neither duplicates itself nor destroys on drop.

The current system is held within a single object which has all the components required for a pickupable object. It is ran with this single graph.

I am familiar with the objectpool, but find it doesn’t allow for the “endless” functionality I may want as the pool is limited by size and I would want it to be scaled by the number of players in the instance. If there is a way to use the pool to make this work I would appreciate a pointer towards how.

Thank you all for your help.

your destroy doesn’t have a reference, as such it won’t destroy anything, you’ll need to get a reference to the object itself in c# it’d be this.gameObject

As for a pool, you’d use a linked list rather than an array, linked lists have the ability to grow and shrink on demand and you can just create a new instance if the pool runs out

I thought that by default if you do not define an input for any gameobject input it would default to this.gameObject…though even with that hard-coded into the graph it does not alter the behavior.

I’m a bit curious how the object pool would act as a linked list, doesn’t it only have the ability to exist as an array? I’m still a bit new to this component and it looks like it can only be used as such.

Udon does not currently support linked lists. And even when it does, the object pool would not work that way because the entire point of a pool is that it is a fixed set of objects that are enabled/disabled rather than being instantiated.

The biggest reason to use a pool is that udon also does not support synced instantiation. So if you want players to be able to see the objects that other players are holding, you can’t instantiate them.

If you want to use a pool, on pickup you would need to send a network event to the owner of the pool to tell them to spawn another item. Then on drop, send another network event telling them to return this object to the pool

If you don’t need them to be synced, then keep going with instantiate. I suspect the reason why you don’t see it duplicate is because you are not setting the position of the clone. It is probably just going to the world origin, so you don’t see it.