Instantiating (i.e. spawning) objects at a specified location?

Momo told me that this is possible using object pools, but I’m not sure of how to implement these with an Udon graph.

If anyone can share a node setup, etc. I would be extremely grateful.

I actually hit the same road block this morning and found that topic as well.

I looked into object pools and it seems to be something about pre-creating the array of objects.

So far I’ve only come up with it seems it’d require some form of int and for loop, to create the amount of objects that you’d need. I’ve not got beyond how to link that up to create the objects in-game yet. The loop would have to somehow read the base object you want to recreate in the loop as well.

This isn’t a solution but maybe it could also help provide some ideas to finding it? I’m still looking and would update if I get it before someone else does. Mines more focused on player joined currently to create an array of player names.

1 Like

Hey there, The way I made it work was by doing a long roundabout.

There are three components:

  1. Spawner
  2. SpawnController
  3. Cloned object

Spawner clones object, sends itself to controller

Cloned object spawns, it also sends itself to controller

Controller sets position of clone to the spawner


That’s a cool solution. Could you share some graph screenshots so I can see how you set up program variables, etc.?

Btw, does your solution require manually specifying the the spawn locations for each controller/spawner?
I have several dozen objects to clone, so I want to reduce dependencies as much as possible.

No, the controller does the job of specifying the location of spawn.

This the spawner:

This the the cloned object:

This is the controller:


Thanks so much for sharing these!

I ended up working on a solution that fits inside a single Udon Program so that less experienced people (like me) can just copy and paste the graph.

I’ll try posting it on here tomorrow.

I managed to come up with this in the end, for cloning an object, (does the children as well).

I’m just working on shifting it to sync to all players and to target a specific child gameobject for the new objects.

Did you test it? From my experience instantiate clone game object doesn’t work at all

Yeah, here’s a in-game screen cap. or two. I use the large cube on the right as an on interact spawner. It then pulls the location variable of where I would like to spawn the cloned object.

I’ve also advanced on it, to instantiate UI objects in a vertical view. I’m now working on targeting the child text fields of instantiated objects to edit them.

Edit: Added the working text replacer and number generator effects. Will post a working graph soon when it’s all done to my needs.

1 Like

Nerzam, thanks for sharing your work.
To clarify what you wrote there, you’re saying that instantiated objects currently don’t sync to all players, correct?

As far as I can tell they’re local. You might be able to find a way of passing something to show on all using the update event though if it’s possible to instantiate udon behaviours on objects.

@nerzarn Have you figured it out yet in terms of modifying the child components? I’m currently in a similar boat but still trying to get past the hurdle of instantiating the ui buttons. Any help would be greatly appreciated.

@Zendrex If you mean you want to change a child within a gameobject. say you have a UI part that instantiates for each player below that you have elements for e.g. the player name, player ID etc. Then after you instantiate, you need to target the new object with a get transform. and use the find, to search the children for the object by name for which you want to change. e.g. say nonmaster text.

Then all you need to do is target the element in that gameobject you wish to change e.g. the text via targeting the component using the type of component you want. You can then set the text string value to whatever you need it to be. e.g. player display name if a player joins.


The only major thing I’ve hurdled on is passing udon behaviour variables to instantiated objects. Though this seems to be on canny.

Mind showing your structure for you’re vertical layout group? I’m getting some errors thrown when I decided to take a crack at your method of getting the buttons in the correct parent.


Also on a side note, have you at all been getting duplicate clones when trying to modify the instantiate of the game object?

Sure thing. so what I do is have a gameobject that holds the Vertical layout group, this sets a place for the new menu items to be parented to. Like so.

Everytime I instantiate I do so to the OwnerButton below that which I then parent to to the Content gameobject. So you see something like this.

This does this each time a new object is instantiated generally through each time an event is fired.

As for the second point, not sure I’ve not actually done my testing through Unity, only in-game. I need to pick up the tool that was on here to do in Unity testing as that might help me with other issues.