#Movement Syncing
1 messages · Page 1 of 1 (latest)
im using the ModularFirstPersonController from the Asset store, but the controller shouldn't be the issue as the position was syncing when I used a ClientRpc to sync positions
Right, but I want to see how you're looping in the ServerRpc with the movement code.
It's quite unlikely the NetworkTransform component is directly the issue. It's a drop and go component.
should i send the file? i'm running it in fixedupdate
Your issue is likely that you're moving the object on the client, sending the position to the server, it's moving the object on the server and then the NetworkTransform is syncing back to the client overwriting the movement they did.
If you want the server responsible for moving a player and syncing that information, the server should be the only one applying updates to transform.position
that makes sense
You would probably want:
- The client sends the Input.GetAxis values to the server with a
ServerRpc - The server runs the movement code and moves the object
- NetworkTransform automatically syncs that movement to all other clients
surely there's a way to just disable the NetworkTransform on the owner though?
That's not a valid solution. Then the local client will be moving their object differently than other clients replicating their movement through NetworkTransform. This will likely lead to desync over time.
You want one source of truth so that everyone gets the same position for the object.
I would go with this if you're wanting the server to control movement of players.
The position, rotation, and scale of a NetworkObject is normally only synchronized once when that object is spawned. To synchronize position, rotation, and scale at realtime during the game, a NetworkTransform component is needed. NetworkTransform synchronizes the transform from server object to the clients.
There's also this if you just want players to be able to move themselves and have it synced without having to send RPCs.