PhotonNetwork.InstantiateSceneObject returns null

Hello again.

I am trying to instantiate a scene object using PhotonNetwork.InstantiateSceneObject, but the function doesn't dispatch an error and returns null. Also nothing is created.
GameObject temp = PhotonNetwork.InstantiateSceneObject(UnitToInstantiate.name, UnitToInstantiate.transform.position, UnitToInstantiate.transform.rotation, 10, null);

Debug.Log("Exists: " + temp); // This is null

Am I doing something wrong here?

Comments

  • Hi,

    Does it work with group=0 ?
    Usually InstantiateSceneObject should write an error in Unity log case it returns null.
  • vadim wrote:
    Hi,

    Does it work with group=0 ?
    Usually InstantiateSceneObject should write an error in Unity log case it returns null.

    Yes, with group = 0 it worked.
    What's group's use? I can't seem to find any info about that.
  • The group can be used as basic interest management. Clients can tell the server which groups they listen to and which they don't need (so they get less updates).
    If this is not working, we will have to take a look for the next PUN update.
  • Sorry for not getting back on topic earlier.
    The problem is most likely that you created an object in a Group that you didn't subscribe to (before).
    Instantiate calls are synced with all clients (always sent in Group 0) but when one arrives for a Group you are not interested in, then the GO will not become created. Instantiate doesn't execute due to the Group not being subscribed.

    This whole thing is a bit tricky. Once a Instantiate is being ignored, it does not execute when you finally subscribe to the respective Group.
    You missed something. It won't execute when you change your mind about Groups later on.
    This will lead to failing RPCs and Destroy calls and due to that Instantiate is actually not a really great tool when using Groups.

    I will think about options how to make things work more seamlessly while actually using Groups. Most likely this means Instantiated GOs from ignored Groups have to be disabled or something.
  • Ah, that makes sense. Thank you for the info.
  • Hello.
    5 years later and I'm tracing my way to this same exact issue for the same exact reasons.
    You have made 0 progress in making this whole group thing any clearer.

    I can't figure out how (or why) to subscribe to instantiate groups, and InstantiateSceneObject does NOT return an error if returning null.
  • JohnTube
    JohnTube ✭✭✭✭✭
    Hi @bibbis,

    Sorry for the inconvenience!
    This has been addressed in PUN2 already and will not be backported to PUN Classic.
    The networking instantiation and PhotonView related features have been refactored with Interest Groups support in mind.