Skip to main content

Player Object Pool Setup

Right now, only one player can enter the station, and everyone else can only see that player rotating properly. The next step is to allow everyone to enter, by giving everyone their own station. Writing a way to distribute an item to all players in an instance can be extremely difficult. Luckily there are prefabs others have written to do this for us. One such prefab is CyanPlayerObjectPool. This prefab requires UdonSharp to work, but you can use it with any Udon compiler. 

Install the following in this order:

  1. https://github.com/MerlinVR/UdonSharp 
  2. https://github.com/CyanLaser/CyanPlayerObjectPool 

The CyanPlayerObjectPool has a readme that lists all the steps on how to create a system that uses it. Since some items are not needed for this guide, they will be skipped. 

  1. First find and drag the PlayerObjectAssigner prefab into your scene. 
    1. This will also add the PlayerObjectPool prefab into the scene. 
  2. Click the PlayerObjectPool prefab and set the pool size to double the world capacity. 
  3. The PlayerObjectAssigner system requires an object that will be duplicated and distributed to all players. Make the station object a prefab and assign the prefab into the PlayerObjectAssigner inspector. 
    1. You will notice that the assigner has spawned the prefab many times as children. 
    2. The readme says this object is required to have two methods and a variable. The station system created should work as is, but you may add these items if you want to add extra behavior outside of this guide.