Instantiated Object is not Synchronizing

Options

I'm running into a problem that I've seen 100 times before on this site but I can't for the life of me figure out what I'm doing wrong in my game. I've tried obvious solutions and I KNOW I'm missing something small here. In short, I spawn players and an object into my game. All have their own "photon view" and "photon transform view". When it comes to playing the game, the players move and can see each other move, but when it comes to moving the object they each move their own instance of the object.

I have confirmed that they are not both instantiating their own object. So what is causing these objects to act independently?

Player Prefab:

Object Prefab:

Instantiation Script:


Answers

  • AnthonyM86
    Options

    Same issue here, commenting to see if this will get answered so I can see the solution too. My players synchronise fine but instantiated NPCs position does not synchronise at all

  • Homertimes
    Options

    only the master client must use PhotonNetwork.instantiate

  • Tobias
    Options

    only the master client must use PhotonNetwork.instantiate

    Any client can use it but .. each client should only instantiate it's own character / unity while only the Master Client instantiates objects that should be controlled only by the Master Client (npcs, etc).

  • Only the master instantiates the loot object (lines 35 and 37 of the code). Are you suggesting that the Master should also be the one that instantiates player characters?

    Isn't that what I am already doing? For context, after the player joins the room they load the current level. Once there the player clicks a 'Ready' button that triggers the SpawnPlayer script. Through this approach the client and host are calling Instantiate on the PlayerPrefab, and the host after spawning the player also spawns the object.

  • AnthonyM86
    Options

    So is it expected behaviour that if a non-master instantiates a moving NPC object with photon transform view, that no other player can see this objects position updated correctly, except for the creator? (sorry to ask here but I can't seem to find the solution anywhere else).

  • I still don't have an answer to this problem. @AnthonyM86, have you had any luck?

  • Tobias
    Options

    Of course it's not expected behavior that only one player sees a networked object the way it's controller sees is. That would be silly for a networking solution...

    So .. actually, it is expected behavior to work, if you follow the PUN Basics Tutorial. There is no better way I could explain this in a brief forum post with the little info I got here.

    Read and code along the tutorial and make sure to experiment with the effects of each mentioned method / component. Then you should be able to solve this, or provide more info to help us help you.

  • AnthonyM86
    Options

    Thanks for the reply.

    I have followed PUN tutorials, and did provide more information in my own topic (https://forum.photonengine.com/discussion/20323/very-puzzling-issue-npc-objects-position-not-syncing-m-networkposition-0-0-0#latest), however received no response so I thought I would add here in this topic where it seems I'm not alone in experiencing this issue.

    As I said in my original post linked above, everything works except sometimes it seems things are randomly not syncing, yet sometimes they are. One would think if it was a complete blunder on my part it would not work at all, yet it seems to work whenever it feels like it.

    Again, to quote my original post in hopes someone can shed some light on this as I have followed the PUN basics and managed to debug and figure out the issue is to do with : "On debugging, it looks like the "m_NetworkPosition" in PhotonTransformView is always 0,0,0 for other players so for some reason I don't think the data is being sent, but I cannot understand why."

    However, on searching the PUN forums and basics tutorial you mention, I cannot see anything that details why the network position is randomly not being sent.

    I'm not the type to post asking for help without trying extensively myself to fix an issue, however it is very hard in this case when m_NetworkPostion seems to be giving the error and I cannot find anything on the docs or forums mentioning this error. Again, objects are being instantiated correctly, have all correct transform view components and observed in transform view, so I am puzzled.

    Sorry for the somewhat long post, but you did say you wanted more info 😏 Hopefully this also helps the others in this thread who seem to be experiencing similar issues.

    Thank you!

  • Tobias
    Options

    Ok, thanks for the context. That makes more sense. I replied in your thread, as I don't know if this is still actively monitored by anyone else.