Hi guys, I have a quick question. I have been creating a multiplayer fps game and now I am working on player movement script. I encountered a problem. The problem is client move faster. But host move normally. Here is my player movement code.
Hi there,
You movement is not independent of frame rate. So whichever game has higher frame rates, that player will move faster. Use Time.DeltaTime to adjust your movement to the framerate.
Ah, actually I used Time.DeltaTime I copied the wrong one, but I used it in the client side Should I use it in the server I mean in the CmdMove function ?
It’s best practice to execute the movement code on the server. You can do the calculation there, and the actual movement. Then use the NewtowrkTransform to sync it back to the clients. If all the calculations and movement are done on the server, it will guarantee they are the same on each client.
The code looks good. Are you using the same input device to test the client and the server? Shouldn’t matter because you are normalizing the input, but thought I’d check.
Yes , I use the same input device to test. I changed the code and click the “Client Authority” in the Network Transform component and now it works well. All character move in the same speed.