Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

How to optimise a ridiculously laggy muliplayer 2D physics game

Discussion in 'Physics' started by Uncleared, Jan 16, 2018.

  1. Uncleared

    Uncleared

    Joined:
    Jan 23, 2016
    Posts:
    8
    So I'm working on a multiplayer game that is 2D. It uses 2D physics quite intensely.

    Basically you run around this map trying to kill many, many zombies which each have a Physics 2D component. Not using Physics is out of the equation, because its needed in order to make them stack, which is a behaviour I want. On top of that, its multiplayer. Does anyone have suggestions?

    Stacking image: https://gyazo.com/f5b3cf9100f5dc52c67d5cd832015eeb
     
  2. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,120
    What's laggy, specifically?

    Are you using NetworkTransform to sync your rigidbodies? If so, are you adjusting the values on it appropriately? Make sure the Transform Sync Mode is Sync Rigidbody 2D, or you'll probably see some jerky behavior. Many of those settings control how much data is sent back and forth. For example, if your rigidbodies don't ever rotate, you can disable syncing that data (Rotation Axis = None). Don't set the Network Send Rate too high, either.

    I think we'd need to know more about the specific lag you're experiencing to help much...
     
  3. Uncleared

    Uncleared

    Joined:
    Jan 23, 2016
    Posts:
    8
    Ah I didn't specify which API I was using. I'm using Photon, not UNet. Well the enemies move in a super jerky way, as well as the players. Its smooth, but the moving entities jerk in weird directions. And when I kill a enemy and its supposed to be destroyed, it gets destroyed after some time instead of immediatly, which breaks the gameplay.