How to sync child objects in Photon Network
I have an object in my scene 'object A'. Object A is a non PUN object, but to object A, object B which is a PUN object is attached to it. Object B is spawned using PhotonNetwork.Instantiate and then it is set as a child of object A using the Unity 3D functions. My problem is if I instantiate object B without setting object A as it's parent Photon will track and synchronize object B amongst the various clients. If I attach object B to object A then PUN stops working. How do I fix this? Thank you.
Answer by Captain_Pineapple · Jan 10, 2019 at 03:45 PM
Do you continue to move B or do you stop moving B and move A instead?
If i'm not mistaken Photon will synchronize LOCAL positions. If no parent is set this will be equal to the global position. If you set a parent the local position will be fixed and not transferred anymore since it never changes.
As a bit of a hacky workaround assuming that you use photons builtin transform synchronization: Manually set the position to synchronize in the transformview script. Perhaps you have to slightly manipulate it by setting some variables/functions to global but it's possible. Already did this some months ago.
Hope this helps.
Your answer
Follow this Question
Related Questions
Unet rigidbody.AddForce not working for clients 1 Answer
Sync weapon switching uNET. 0 Answers
Photon synchronization on different devices failes 0 Answers
Sync data to different players 1 Answer