Why InstantiateSceneObject needs to be through MasterClient?

Pretty much what the title is asking. I would like to instantiate scene objects as any player. So when that player leaves the objects they made do not disappear.

For now I made a relay system to ask the MasterClient for a scene view object, its viewid, and ownership, but I would rather just instantiate it as any player and not use the work around.

Thanks!

Comments

  • Asking master via RPC to spawn scene object is absolutely fine. Master creates and owns scene objects. Other means like ownership takeover may work but would be much more complicated.
  • Hello thank you for the response!

    I have built an RPC that takes a string and PhotonPlayer and "asks" master to spawn and give a scene object using photonView.TransferOwnership(player)

    but the difficult part is then giving the player that gameobj in the script i call the rpc from like calling instantiate scene object does.

    Can you help me figure out a way to do this? Can I manually instantiate and allocate a scene view id like the tutorial on the website?

    Thanks again for the help!
  • It's not clear what are you trying to achieve. You either create scene object on master or plain object on one of clients. You hardly need to transfer ownership.
  • brainversation
    edited October 2015
    I need a scene object so it doesn't get destroyed when the player leaves. That is the main reason for this work around. I have looked into turning off auto cleaning but there isn't much documentation on what auto cleaning does and how I can manually do that.

    So pretty much what I need is a networked item with all the normal functionality, like synced position, ownership transfer, and so on....that doesn't get destroyed when the player leaves.

    Also what would help is if ownership is transferred, if the new owner cleans up the objects not the creator.

    Hope that makes sense!

    Thanks again for the help.

    PS is there a way to get notifications when you reply?
  • Scene objects (created with PhotonNetwork.InstantiateSceneObject) are designed exactly for what you need. They are never destroyed but can be controlled by master client only.
    Why they are not good for you?
  • brainversation
    edited October 2015
    @vadim They are what I need and are great but the problem is that I can only called it as master client. It is also the thing I do not understand.

    Lastly, I also need it to return the gameobject at the line of code that instantiate it at.

    Thanks again.
  • vadim
    vadim mod
    edited October 2015
    If you need to trigger creation on client other than master, send rpc to the master asking him to create scene object.
    Lastly, I also need it to return the gameobject at the line of code that instantiate it at.
    It's not clear why you need that, but I'm pretty sure that you can achieve the same on non-master client with OnPhotonInstantiate handler.
  • @vadim Thanks I used OnPhotonInstantiate to do what i wanted but its still a silly work around.

    We can mark this as solved for now but can you please explain why only master client can instantiate scene objects?

    Thanks again!
  • It's a technical limit. There is a small range of viewIDs for scene objects and it's easier to manage, if only one client will allocate and assign IDs in that range, than everyone. This way, we can hand out IDs much faster than when you have to sync their usage.
    I don't have a good idea to solve this yet. We could sub-divide the range, to allow each client it's own scene-object ID range probably.
  • @Tobias That sounds like a great idea! Maybe it can be an option with a limit and then if limit is reached the player has to go through master client?
  • I fear I won't have a lot of time to improve this soon. In best case, you take a look at the source and see if you can do something with it. Inside of PUN, it should be simpler than coming up with an external solution.
    That means, however, that updates will be more hassle.
  • Thanks for the feedback, I found a workaround for now and do not have time to look through PUN and make it work. I really appreciate the help and I will wait for the update.

    Thanks again.
  • @brainversation Can you please share the workaround?
  • @Hasnain This was a while ago so I'm not sure the exact way I did it. I believe I put the PhotonPlayer's ID in the SceneObject's InstantiationData variable. Then in OnPhotonInstantiate I checked it against the local PhotonPlayer's ID and if it was a match I used photonView.TransferOwnership(PhotonPlayer). Make sure the attached PhotonView's OwnershipOption is set to Takeover or Request based on what functionality you want.

    Hope that helps!