question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NetworkTransform doesn't sync data with new connected client.

See original GitHub issue

Describe the bug I synced the transform position of my doors. It’s well synced when the host or the client trigger the button to open the door or close the door. But if my host open the door when my client is not connected, when the client connect to the host, the door which is open on the host, is closed on my client.

To Reproduce

  • Create a gameobject with a NetworkObject and a NetworkTransform component.
  • Start Host
  • Move the object on the host side
  • Connect a client to the host => The object is still at the original position on the client side, which is not the host side object position.

Expected behavior When the client connect, the server should send all actual position of NetworkTransform objects to the new connected client. The client should apply all the positions of these objects before allowing the user to play.

Screenshots unknown

Environment (please complete the following information):

  • OS: Windows 10
  • Unity Version: 2020.3.0f1
  • MLAPI Version: 12.1.7
  • MLAPI Commit (not sure it’s the good one tho)

Additional context Luke helped me to find a workaround and use this part of the code :

if (!IsOwner)
{
    if(!isDoorOpened.Value){
        GetComponent<NetworkedTransform>().Teleport(originDoorPosition, Quaternion.identity);
    }else
    {
        GetComponent<NetworkedTransform>().Teleport(new Vector3(originDoorPosition.x, 3, originDoorPosition.z), Quaternion.identity);
    }
}

It works well. He told me that’s because the server doesn’t send the actual position and when I try to move any NetworkTransform object by updating it’s position or translate it directly on the client, that doesn’t work because the NetworkTransform will automaticaly remove the object to the last known position. By using the Teleport method on the NetworkTransform component, it update the known position of the component which will be the same as the server, so it’s fine.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
will-mearnscommented, Mar 29, 2021

We are aware of this and a future MLAPI version will address it

0reactions
newFort4commented, Oct 10, 2022

Hi, @ashwinimurt . In release 1.0.2 version this issue still exists. Found a workaround to set position threshold to 0.

Pros: really fast solution Cons: send package each tick, still need one tick when connects to sync.

With tick rate set by default (30) sending 3 floats during 1 minute takes: 3 * 4 * 30 * 60 = 21600 bytes ~ 21 kilobytes. I think is not so bad.

Please correct me if I am wrong.

Read more comments on GitHub >

github_iconTop Results From Across the Web

NetworkTransform doesn't sync data with new connected ...
Create a gameobject with a NetworkObject and a NetworkTransform component. ... => The object is still at the original position on the client...
Read more >
NetworkTransform not working on client
So I'm trying to sync movement between two programs using UNET. I have them connecting fine, and seeing eachother/registering the player ...
Read more >
Client's objects movement not syncing across the Network
Therefore, the movement is not syncing. I already attached NetworkIdentity, NetworkTransform, and PlayerController script to it. As well as the ...
Read more >
NetworkTransform
This means that changes to transform axis (marked to be synchronized) are detected on the server-side and pushed to connected clients.
Read more >
sync direction from client to server not workin in Unity ...
I am trying to make a multiplayer game using mirror networking m The sync direction from server to client works fine but nothing...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found