In PUN 2.20.1 lib 4.1.44 gameobjects have stopped changing their parent in MasterClient = false.

Volk
Volk
Hello!
Sorry for my English! :)

In PUN 2.20.1 lib 4.1.44 gameobjects have stopped changing their parent in client IsMasterClient = false.

I found this in the code and had to put an additional check, if gameobject did not change the parent - to change it.

If IsMasterClient = true changes the parent of a PhotonView gameobject, so IsMasterClient = false leaves this object at the root of the scene.

There was not in previous PUN versions.

Not only that, now the gameobject coordinates are getting lost and I have to adjust the coordinates by RPC.

Please tell me why such amendments were made or maybe I don't understand something?

Where can I enable automatic parent change in PhotonViewObject now?

Thanks!

P.S. The Freez Position checkboxes do not affect anything - do not pay attention to this.

A.png

Comments

  • There have been changes to how IsMine, owner and controller work, and changes were made to make nesting photonviews possible.

    I can't quite make sense of your question though. There is code now that detaches nested photonviews if a parent pv is being destroyed, and the nested child PV shouldn't be destroyed, The child gets detached before the destroy happens.

    Not sure if this is related.

  • Volk
    Volk
    edited August 2020
    emotitron wrote: »
    There have been changes to how IsMine, owner and controller work, and changes were made to make nesting photonviews possible.

    I can't quite make sense of your question though. There is code now that detaches nested photonviews if a parent pv is being destroyed, and the nested child PV shouldn't be destroyed, The child gets detached before the destroy happens.

    Not sure if this is related.

    And I don't quite understand the meaning of your answer.

    My question is why now if MasterClient puts PhotonViewGameObject inside another GameObject, then IsMasterClient = false PhotonViewGameObject does Not change its parent?

    And what should I do now to save the hierarchy in IsMasterClient = false automatically as before?

    Should I now control my parents in MasterClient = false and send every second an RPC to correct the coordinates? But that's not normal. :(
  • Can you provide us with a minimalist showcase? Some scene that shows what's happening and you explain what you expect instead?
    Use primitives and simple PhotonTransformView components to help us get the use case.
    Mail the project to: developer@photonengine.com
  • Volk
    Volk
    edited August 2020
    Tobias wrote: »
    Can you provide us with a minimalist showcase? Some scene that shows what's happening and you explain what you expect instead?
    Use primitives and simple PhotonTransformView components to help us get the use case.
    Mail the project to: developer@photonengine.com

    It's simple. Two players enter their characters (PhotonViews) into the room (in the root). MasterPlayer grabs a machine gun (the machine gun is also on the scene in the root and is also a PhotonView) and the machine gun changes its parent to the MasterPlayer. In another player (NotMasterPlayer), the machine gun doesn't change the parent, but just stays in the root.

    In previous versions everything worked well, but now I have to install the correct parent in NotMasterPlayer with such stupid checking:
    
    if (_gun.transform.parent != _character.gameObject.transform) {
                    Vector3 pos = _gun.transform.position;
                    _defaultGunGlobalPosition = new Vector3(pos.x, pos.y, pos.z);
                    _gun.transform.SetParent(_character.gameObject.transform);
    }
    
    
    }

    That's all.

    P.S. The same thing will happen if NotMasterPlayer enters the room after MasterClient has grabbed the machine gun. Previously, this was controlled by Photon (or Unity - I do not know), and now the programmer. Maybe I don't understand something? Please explain to me. :)

    P.S. If a NotOwner grabs a machine gun, the machine gun is passed under its influence via photonView.RequestOwnership().
  • If I am reading that right, you are expecting parent changes to automatically be synced? If that is what you mean that has never been the case and you would have to sync those changes yourself with RPCs or by serializing the parenting info through an Observable.

    If it worked before, there was something else going on in your scripts that was allowing that?
  • emotitron wrote: »
    If I am reading that right, you are expecting parent changes to automatically be synced? If that is what you mean that has never been the case and you would have to sync those changes yourself with RPCs or by serializing the parenting info through an Observable.

    If it worked before, there was something else going on in your scripts that was allowing that?

    >>>If I am reading that right, you are expecting parent changes to automatically be synced?<<<

    Yes. And so it was until version PUN 2.20.1 lib 4.1.44 since I did not change the code in this block for 6 months and everything worked fine (the game was constantly tested in multiplayer mode) - I specifically checked it. And then, I noticed that machine guns stopped changing the parent - this is very easy to notice in the scene (game). And I had to put the code block specified above. But, not only that, in the new version, now there are sometimes oddities with the coordinates of the machine guns - they either work normally, or they can fly around the entire scene without syncing the coordinates.
  • I will try to update to version 2.21 now... :)
  • And so it remained. The change of parent is not synchronized. :(
  • Volk
    Volk
    edited August 2020
    emotitron wrote: »
    If I am reading that right, you are expecting parent changes to automatically be synced? If that is what you mean that has never been the case and you would have to sync those changes yourself with RPCs or by serializing the parenting info through an Observable.

    If it worked before, there was something else going on in your scripts that was allowing that?

    >>>If that is what you mean that has never been the case and you would have to sync those changes yourself with RPCs or by serializing the parenting info through an Observable.<<<

    Ok. Well, if you're so sure. But I suspect that wasn't always the case. Then I will use RPC for synchronization, but I still think it is wrong from the point of view of logic! IMHO - Then it turns out that this is not a complete synchronization on the part of PUN. This is a pun! ))
  • Pun on PUN intended? :smile:

    PUN never had synchronization for parenting. We actually didn't even allow it earlier on and now it's at least possible to do.

    And yes, there are a few things PUN doesn't do. We try our best to balance features versus complexity and also prioritize topics that get requested more often. Let us know what you're missing and we consider it.
  • Volk
    Volk
    edited August 2020
    Tobias wrote: »
    Pun on PUN intended? :smile:

    PUN never had synchronization for parenting. We actually didn't even allow it earlier on and now it's at least possible to do.

    And yes, there are a few things PUN doesn't do. We try our best to balance features versus complexity and also prioritize topics that get requested more often. Let us know what you're missing and we consider it.

    I understood. :) I was incorrectly sure that synchronization for parenting worked. Too bad it doesn't work. Okay, thanks for the explanation! then I will try to solve the problem without parent synchronization. Now I see why there are strange displacements of machine guns (PhotonViews) if they have parent.

    >>>Let us know what you're missing and we consider it.<<<
    Thanks! Let me first try to solve the problem without parent synchronization, and if I can't, I'll tell you more about what I want to achieve. :)
  • Volk
    Volk
    edited August 2020
    Tobias wrote: »
    Pun on PUN intended? :smile:

    PUN never had synchronization for parenting. We actually didn't even allow it earlier on and now it's at least possible to do.

    And yes, there are a few things PUN doesn't do. We try our best to balance features versus complexity and also prioritize topics that get requested more often. Let us know what you're missing and we consider it.

    Could I temporarily disable the transform synchronization in PhotonView NotMasterPlayer?
  • Volk
    Volk
    edited August 2020
    Thank you all for your help! The problem was solved very simply! In Update(), the local coordinate of the parent object (PhotonView) was converted to a global coordinate and assigned to the machine gun (PhotonView), which is always located at the root of the scene. That's it! You are right not to allow parent synchronization! The question is closed! :)
  • Thanks for the update! :smile: