Can't work out multiplayer with Mirror
So I'm building a simple 2D game with 2 players (seen from a side). The game works just fine in singleplayer, even when I control both of the players at the same time from my PC. The goal is to make it into an online multiplayer game, therefore I used Mirror, set everything up for the players and in Unity itself, but no matter what setting I change, the physics between the 2 instances (running both on the same PC) are very jittery. The movement from left to right is fine, but when I jump with one player, it is incredibly jittery in the second client. Same when one player slowly slides down on an angled platform. It is a little bit better when I move the player on the client side that's also the server of course.
I know it most probably has to do with physics being calculated in the client and then sent to the server and so on, but I just can't find a good solution for this. And this is just simple player movement, I haven't even gotten to the meatier stuff yet...
Any suggestions for me, please?
Answer by GetLitGames · Jul 12, 2021 at 04:48 PM
Multiplayer frameworks don't do anything special for physics, they just replicate the position and rotation of your objects. Most likely what is wrong is that you still have the RigidBody on the client copies. The actual object being controlled is telling the replicated copies where to be, but because you have the RigidBody and colliders on the replicated copies they are bouncing on their own and snapping back into the position that they are told to be in by the controlled version of the object. The specific code solution depends on if you are doing full server authoritative or client auth. But you need to determine when they are created whether they are a replicated copy or the local player's version. Replicated copies should have the RigidBody component destroyed and any types of control/player input scripts removed. They are merely there for visuals and shouldn't interact with physics, although quite often people leave the colliders on them so they can still use collision callbacks - but if you do that you will need to be aware of how that callback code is being used and in what context you are (remote copy, or local player). If you are just starting out, you probably have things setup as client auth, meaning your local player controls his own body and position and just destroys itself when you die, sets it's health remaining via scripts with vars that are replicated etc. I can't be specific about what to do since I don't how your multiplayer is designed but this information should help you. Be aware that Mirror works well for dedicated servers, but if you want players to run hosts on their own PCs like Minecraft you may want to consider using Photon Bolt or Photon PUN instead. Mirror may have a solution but it's not going to be as seamless as using Photon. Photon Bolt is very easy to get started and you can Google the Photon Bolt Tutorial and it's Getting Started page here: https://doc.photonengine.com/en-us/bolt/current/demos-and-tutorials/bolt-basics/bolt-102-getting-started
Your answer
![](https://koobas.hobune.stream/wayback/20220613040157im_/https://answers.unity.com/themes/thub/images/avi.jpg)