Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by Vondohr · Jul 12, 2021 at 12:17 PM · multiplayerunity 2dmultiplayer-networking

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?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

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

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

257 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How can I Instantiate only one GameObject Using PhotonNetwork. 0 Answers

Unity Photon how to show arm/gun movement with mouse to other players.,Unity Photon: How to show arm movement to other players 1 Answer

NetworkServer is not active. Cannot spawn objects without an active server. 0 Answers

my friend can't join my multiplayer game! 0 Answers

How to make multiplayer checkpoint's 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges