How to work with addressable x resources

Hi hi, I'm going to the adressables path to download content from my online game. Currently photon precasts should be in the resources folder. So how am I supposed to work here? Can someone give me some light?

Comments

  • Async loading is not supported by Instantiate. When anyone instantiates an object, each client needs a proxy for this.
    What you could do, however, is have a "light" prefab for the networked object. This could then load the visuals and apply them as needed.

    Implement a IPunPrefabPool and assign it as PhotonNetwork.PrefabPool. Make it load the addressables before they are needed and you can get rid of the Resources.

    Check out the API reference for the IPunPrefabPool for details on what it must provide.

  • jc_kolbapps
    edited June 2021
    Hi Tobias, Thanks for responding. I understand the concept behind your idea. But I don't understand how to work with PunPool. I checked the documentation but didn't find anything practical to follow.

    If I'm not asking too much, could you show me an example?
    I currently have something very simple in my project:

    1 - My room, start, instantiating the player:
            private void Start()
            {
                 ...
                //This is a empty prefab. Only to choise the correct prefab for the player. 
                PhotonNetwork.Instantiate(photonPlayer, Vector3.zero, Quaternion.identity);
            }
    

    2 - The prefab instantied from room (photonPlayer), is a empty prefab, only to choise a correct prefab for the player controller. So the photonPlayer prefab it will be to instantiate an other prefab. This other prefab will be to used for the player controller. Its a prefab with all that de player need, like as model, animations etc etc…
    - PhotonPlayer Instance:
            private void Start()
            {
                if (!isMine)
                    return;
    
                PhotonNetwork.Instantiate(playerController, Vector3.zero, Quaternion.identity, 0, new object[] { photonView.ViewID });
            }
    


    Using your theory, I will make this prefab (from the player controller), to an empty container too, and it will be to instantiate a prefab of my addressable reference, with everything my player needs. This can really work. Right?

    But, I had never heard of the photon pool until now. I don't understand where to implement this.
    Using the code references above, where do I start working with the Pool?


  • Sorry for the late reply. I had a draft in the text field but didn't send.

    There is actually also a doc on the pool (forgot to point out):
    https://doc.photonengine.com/en-us/pun/current/gameplay/instantiation/#using_the_prefabpool

    Well. Empty is not the correct wording. You need a core / skeleton prefab, which can fully handle network updates. It just doesn't need visuals and so on. Those can be loaded async and this is the benefit this gives you.

    Alternatively, as said: Pre-load the assets you need for networking. You can do this from a pool.