Search Unity

  1. Calling all beginners! Join the FPS Beginners Mods Challenge until December 13.
    Dismiss Notice
  2. It's Cyber Week at the Asset Store!
    Dismiss Notice

Unity Multiplayer Transform updates NOT appearing on the client hosting the server

Discussion in 'Connected Games' started by GreenBoxInteractive, Jun 25, 2015.

  1. GreenBoxInteractive

    GreenBoxInteractive

    Joined:
    Mar 23, 2015
    Posts:
    135
    Hello.

    I have this code, just to test out the multiplayer system.

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using UnityEngine.Networking;
    4.  
    5. public class CC : NetworkBehaviour {
    6.  
    7.     public int speed;
    8.  
    9.     void Update () {
    10.         if(!isLocalPlayer){
    11.             return;
    12.         }
    13.             if(Input.GetKey(KeyCode.W)){
    14.                 transform.Translate(Vector2.up * speed * Time.deltaTime);
    15.             }
    16.             if(Input.GetKey(KeyCode.S)){
    17.                 transform.Translate(Vector2.up * -speed * Time.deltaTime);
    18.             }
    19.             if(Input.GetKey(KeyCode.D)){
    20.                 transform.Translate(Vector2.right * speed * Time.deltaTime);
    21.             }
    22.             if(Input.GetKey(KeyCode.A)){
    23.                 transform.Translate(Vector2.right * -speed * Time.deltaTime);
    24.             }
    25.      
    26.     }
    27. }
    28.  
    It just moves a cube about.

    I then have a network manager, with these settings:



    and my cube prefab has a Network Transform component with these settings:



    My problem is that the positions are only correct on the connected client. So the host client's cube updates on the connected client, but the connected's cube doesn't update on the hosts client.



    Any help? I'm new to networking.
     
    Last edited: Jun 25, 2015
  2. SuperNeon

    SuperNeon

    Joined:
    Mar 16, 2014
    Posts:
    85
    Hi !

    Ensure your GameObject have the authority checkbox checked in the NetworkIdentity component.
     
    Maras and GreenBoxInteractive like this.
  3. GreenBoxInteractive

    GreenBoxInteractive

    Joined:
    Mar 23, 2015
    Posts:
    135
    Nevermind!!! I fixed it by checking multiple client mode in the network manager
     
  4. GreenBoxInteractive

    GreenBoxInteractive

    Joined:
    Mar 23, 2015
    Posts:
    135
    This too, I had this already though