Search Unity

  1. We're looking for feedback on Unity Starter Kits! Let us know what you’d like.
    Dismiss Notice
  2. Unity 2017.2 beta is now available for download.
    Dismiss Notice
  3. Unity 2017.1 is now released.
    Dismiss Notice
  4. Introducing the Unity Essentials Packs! Find out more.
    Dismiss Notice
  5. Check out all the fixes for 5.6 on the patch releases page.
    Dismiss Notice
  6. Help us improve the editor usability and artist workflows. Join our discussion to provide your feedback.
    Dismiss Notice

Not same position on every clients

Discussion in 'Multiplayer Networking' started by Zeldarck, Aug 13, 2017 at 10:18 AM.

  1. Zeldarck


    Feb 8, 2017

    I try to learn networking in Unity, I want to make my pong game multiplayer:

    I have follow this tutorial to get the basis of networking :

    In my pong, I want a player see hiself on the bottom of the screen.
    So If I have well understand we have that :
    Device 1 : got server and client 1
    Device 2 :got client 2

    On client 1 and server, we got client 2's player position at the top and client 1's player position at bottom.
    But on client 2 I want client 2's player position at bottom and client 1's player position at top.

    I tried to modify a little the tutorial exemple and change the position in the PlayerController, but I see a fantomatic player at the two place.

    Code (csharp):
    2.         if (!isLocalPlayer)
    3.         {
    4.             if (!isServer)
    5.             {
    6.                Vector3 pos = transform.position;
    7.                 pos.x *= -1;
    8.                 pos.y *= -1;
    9.                 transform.position = pos;
    10.             }
    12.             return;
    13.         }
    I will continue to search alone and test further things, but I you have good advice or better approach I am open to.
    For exemple I don't know if command enter by player have to be send to server wich make movement and send back position of ball/objects/players. Or if like in the tutorial, players make move, send them to the server wich send it to other players. For me the first it's better, but with local interpolation to not wait the server update. But I really don't know enough and where search first on unity networking to achieve it :)

    thank you

  2. Joe-Censored


    Mar 26, 2013
    I haven't looked at your project, so don't know if it is 2D, 3D, etc, but the first way I would attack this would be rather than trying to swap in game positions of the 2nd player I would see if I can just flip the 2nd player's camera upside down.
  3. Zeldarck


    Feb 8, 2017
    OH thank you !
    I didn't think at that trick, I don't enough think of the view is determine by camera :)