Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing NetworkVariable value make NetworkTransform do not sync from client to server #3188

Open
DevloCore opened this issue Jan 1, 2025 · 1 comment
Labels
Investigating Issue is currently being investigated stat:awaiting response Status - Awaiting response from author. stat:awaiting triage Status - Awaiting triage from the Netcode team. type:bug Bug Report

Comments

@DevloCore
Copy link

Description

After changing a networkvariable value on a networkobject, client never sends transform changes to the server, until server gain ownership again.
Important: This bug happens in NGO v2.1.1 AND v2.2.0. In the version 2.0.0, this bug does not exist.

Reproduce Steps

Create a gameobject in your scene. Add the following :
Image

Create a script that has a networkvariable and attach it to the same gameobject.

public NetworkVariable<bool> movingStateObject = new(readPerm: NetworkVariableReadPermission.Everyone, writePerm: NetworkVariableWritePermission.Server);

For example, on key pressed, change the Value of the network variable, then change ownership.
Here is an excerpt of my code :

if(holdOrHandObject)
{
    movingStateObject.Value = true;
}

if(id == NetworkManager.ServerClientId)
    SendControlToPlayer(true);
else
    NetworkObject.ChangeOwnership(id);

When a client (not server) gains the control, he can move the object. This can only be visisble by him. For the server, the gameobject do not move at all.
In the opposite case (server gains the control to move the object), it moves both on server and client, no matter if networkvariable value change.
I tried to stop setting movingStateObject.Value, and the problem disappears. Weird.

This bug happens in NGO v2.1.1 AND v2.2.0. Simply downgrading to v2.0.0 fixes the bug.

Sorry for my english, if you need more information, just comment and I will answer as soon as I can. Thanks.

Environment

  • OS: Windows 11
  • Unity Version: 6000.0.28f1
  • Netcode Version: 2.1.1 AND 2.2.0
@DevloCore DevloCore added stat:awaiting triage Status - Awaiting triage from the Netcode team. type:bug Bug Report labels Jan 1, 2025
@NoelStephensUnity
Copy link
Collaborator

NoelStephensUnity commented Jan 6, 2025

Hi @DevloCore,

What is the write permissions for movingStateObject?

Could you check which write permissions are set for that NetworkVariable and then only change the NetworkVariable if the client instance has permissions and see if that fixes the issue you are experiencing?

If not, could you provide more of your script so I can better understand other things that could be causing this issue?

@NoelStephensUnity NoelStephensUnity added stat:awaiting response Status - Awaiting response from author. Investigating Issue is currently being investigated labels Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Investigating Issue is currently being investigated stat:awaiting response Status - Awaiting response from author. stat:awaiting triage Status - Awaiting triage from the Netcode team. type:bug Bug Report
Projects
None yet
Development

No branches or pull requests

2 participants