MirrorNetworking / Mirror

#1 Open Source Unity Networking Library
https://mirror-networking.com
MIT License
5.15k stars 764 forks source link

Player movement stutters on Wi-Fi but works almost fine on mobile data. #3893

Closed SudarshanShetty1796 closed 1 month ago

SudarshanShetty1796 commented 1 month ago

In my 2D game, I'm using a dedicated headless server architecture and KCP transport. I send the joystick direction to the server, and the server moves the character via serverRigidBody2D.velocity = velocity. Each character has a NetworkTransform (Unreliable) component attached, which syncs player movement across all devices. The movement is handled server-side, not client-side; the client only sends the direction to the server.

The network manager's send rate is set to 75, and the client sends input updates 30 times per second. The NetworkTransform (Unreliable) component has interpolation for position enabled, and all other configurations are kept at default values.

The issue is that player movement stutters on Wi-Fi on my Realme device, but when I switch to mobile data, it works much better (though not perfectly), even though the ping rate is higher on mobile data than on Wi-Fi. Despite this, the frame rate and ping values at the bottom left of the screen are fine. I also profiled my game on the same device, and it consistently runs at 60 FPS. Initially, I thought the stutter might be due to the camera, but after disabling camera tracking, I noticed that the stutter occurs from the Mirror-controlled character itself while syncing position. How can I tackle this? Has anyone else encountered a similar issue?

With the same Wi-Fi and the same app, if I run it on my Vivo device, it runs smoothly. I'm finding this issue on mid or lower-end devices despite having a good ping rate as well as a consistent 60 FPS frame rate, and the issue occurs all the time on those devices.

Unity version 2021.3.26f1 Mirror version: 89.14.2 Issue screen recording link: https://drive.google.com/uc?export=download&id=106w23sXALgwLgpAoMQ3EtRgqOP38Gn0p

Thanks

SudarshanShetty1796 commented 1 month ago

The same stuttering issue is present in the Mirror TopDownShooter example project as well. I haven't modified anything apart from adding a joystick to take input on mobile devices. In the example project, the opponent character stutters if you closely observe it. This issue does not occur with the local character since the input is synced from client to server in the example project. Please help me tackle this issue.

https://github.com/user-attachments/assets/d9a2b302-7346-4993-9621-c26d357fac76

MrGadget1024 commented 1 month ago

closing this - answering in Discord