Can I get NetworkTransform to sync local coordinates instead of world coordinates?
I'm working on a simple game, where the clients are running what's essentially a different scene than the server. When a client adds a player, I'm also sending a position and rotation to serve as an offset of their synced position and rotation.
To initially test the idea, I reparented the client's player to another object on the server, then moved that object in the editor. I expected the player object to still move normally just at an offset location. Instead, whenever the NetworkTransform is synced, the world position and rotation are set instead, and the player snaps to that position regardless of how I move the parent on the server.
How can I sync the local coordinates instead? Would a syncvar work for such a thing? I have almost no experience at all with UNET.
I hope this is clear enough. Thank you very much.
Answer by jethrogillgren · Jan 29, 2018 at 03:21 PM
You can do this using NetworkTransformChild
Put, on a parent object, a NetworkTransform with SyncMode "None". Also, on that same object, add a NetworkTransformChild and drag the child you want to Sync onto the "Target" field.
The Child will now have it's localTransform synchronised.
Your answer
Follow this Question
Related Questions
How to sync RPC function Photon Network? 1 Answer
How to use SyncListStruct properly? 0 Answers
Network Rotation not sync 2 Answers
[uNET] Network objects spawned not spawn in new clients 1 Answer
Unet Syncing Flashlights 2 Answers