Player on the same side

Hi, I can't seem to figure out how to go about it.
I want the player always to be on the left side of the screen and the enemy on the right side. To be more specific, I want to SyncedInstantiate a minion on "my" side of the board, which is always left, by dragging an item onto the board and then using the Input.mousePosition to get the coordinates.

I tried checking if the player is local player, instantiate at a position and if he's not the local player, instantiate at a different position, but the clients get desynchronized ( Checksum : NOK ).

And after that i'm interested in making the minion move towards enemy ( which again is always on the right side ).


  • If anyone is interested, I thought about a fix and for now it's working, going to see later on if this creates some other type of problems when minions decide for themselves to attack enemies, but for now it's fine.

    As far as I understood in about 2 days of testing, every time the host of the game (the one who presses start in TrueSync demos) is always player with id 1 and the other is with id 2 ( i have only a 2 player game, so it works for me ).

    Each player has variables that know which player he is, something like

    IsPlayer1 = TrueSyncManager.LocalPlayer.Id == 1;
    IsPlayer2 = TrueSyncManager.LocalPlayer.Id == 2;

    Now that i have this info, in "OnSyncedInput()" i do this :

    if (IsPlayer1)
        TrueSyncInput.SetByte(Const.SPAWN_CHARACTER, 1);
    else if(IsPlayer2) TrueSyncInput.SetByte(Const.SPAWN_CHARACTER, 2);
        else TrueSyncInput.SetByte(Const.SPAWN_CHARACTER, 0);

    After that, in "OnSyncedUpdate()" :

    whichPlayerSpawns = TrueSyncInput.GetByte(Const.SPAWN_CHARACTER);
    if (whichPlayerSpawns == 1)
    if (whichPlayerSpawns == 2)

    Saying basically : if player 1 spawned the minion, move it to the right ( towards player 2 ) and if player 2 spawned the minion, move it to the left ( towards player 1).

    One more step :)
    I made 2 cameras, one looking at the scene normally and a copy of it having it's view mirrored. For player 1 i activate the normal camera, for player 2 i activate the mirrored camera. It's a 2d sideview game, so it works.

    This is how i did it. To be honest, I consider it a "hack", a temporary solution until an official TrueSync developer answers and suggests a better way to do this.

    Technically it's SOLVED, but I personally don't like the solution.
  • Hello @IonutzTamas, the main thing to have in mind about the sync issue is that all actions you send need to happen the same way in both machines, for example, the first time you get the issue the Player A (in machine A) instantiate an unit in position X, but the same unit related to Player A was instantiated in position Y (when in machine B), this will create a desync situation as machine A and machine B has different position for the same object.

    For the thing you want to solve you have to make all movements being equals (as your second solution), you can start thinking about of Player A always instantiante on left side and send them run to the right border, and Player B instantiates on the right side and send them run to left border. As you know this will be synced but you want local player to be in the left side, so you can try some camera rotation (or two cameras as you did) to give a different view for Player B, as he is in the left side, but under the hood it is on the right side (based on Unity's coord system).