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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Car collision in a multiplayer game

Discussion in 'Multiplayer' started by Deleted User, Nov 5, 2015.

  1. Deleted User

    Deleted User

    Guest

    Hey all,

    I'm having a little problem with collision between 2 cars in a simple multiplayer instance. When the cars collide, the car which rams the other car just drills under / through the other car, sometimes glitching both cars in to the air instead of knocking it away(like in a real collision). Also after a collision, the car which isn't controlled by the player, begins to glitch a bit and its movement doesn't look smooth anymore(I'm using lerp to make the movement smooth).

    If anyone knows a sollution regarding this issue would be helpful.
     
  2. Skerbey

    Skerbey

    Joined:
    Oct 15, 2015
    Posts:
    11
    Are you moving these cars by updating their positions or by applying forces to their RigidBodies?
     
  3. Deleted User

    Deleted User

    Guest

    By updating their positions
     
  4. Skerbey

    Skerbey

    Joined:
    Oct 15, 2015
    Posts:
    11
    I think that both the server and client are trying to simulate the physics of the collisions independently. Each one simulating with the past version of the other players car so they will determine different outcomes. The glitching would be because a force is applied to the non-owned car from the collision causing the car to move but it is still receiving positional updates from the server so it jumps to position and still moves with the force form the locally calculated position.

    I have had issues like this before and usually my solution is to freeze all constraints on a RigidBody's RigidBodyConstraints on non-owned objects so they only receive positional updates from the server and don't try to move them themselves.

    I hope that was clear.
     
  5. Deleted User

    Deleted User

    Guest

    I will try that method right now, thanks for still replying!