Search Unity

  1. Unity 2019.1 beta is now available.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. We're looking for insight from anyone who has experience with game testing to help us better Unity. Take our survey here. If chosen to participate you'll be entered into a sweepstake to win an Amazon gift card.
    Dismiss Notice
  4. On February 28th the Feedback website will shut down and be redirected to the Unity forums. See the full post for more information.
    Dismiss Notice
  5. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  6. Unity 2018.3 is now released.
    Dismiss Notice
  7. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

Transferring Data between Lobby and Game Player Prefab?

Discussion in 'Connected Games' started by Doomer022, Jul 10, 2018.

  1. Doomer022


    May 16, 2018
    My usernames are STILL not working, and team colors dont get transferred from the lobby player prefab to the game player prefab. Please Answer!

    Lobby scene:
    - The host can see everyones username and colors
    - The clients can only see their own username and colors, sometimes. I dont think it gets updated as commonly as it should.

    Game scene:
    - Everyone sees everyone in their chosen color, everyone can see everyones name, but the host's name changes back to just the default "Username". Well thats something!


    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.Networking;
    6. public class PlayerTeamManager : NetworkBehaviour {
    8.     public Transform carLobbyTR;
    10.     public GameObject carPlayer;
    12.     public static string CarLobbyColor;
    14.     public void OnCollisionEnter(Collision collision)
    15.     {
    16.         if (collision.gameObject.tag == "RedTeamPlatform")
    17.         {
    18.             this.GetComponent<MeshRenderer>().material.color =;
    19.             carPlayer.GetComponent<MeshRenderer>().material.color =;
    20.             CarLobbyColor = "Red";
    21.         }
    22.         if (collision.gameObject.tag == "BlueTeamPlatform")
    23.         {
    24.             this.GetComponent<MeshRenderer>().material.color =;
    25.             carPlayer.GetComponent<MeshRenderer>().material.color =;
    26.             CarLobbyColor = "Blue";
    27.         }
    28.     }
    29. }

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.Networking;
    6. public class PlayerTeamLobbyColorGet : NetworkBehaviour {
    9.     void Awake () {
    10.         if (PlayerTeamManager.CarLobbyColor == "Red")
    11.         {
    12.             this.GetComponent<MeshRenderer>().material.color =;
    13.         }
    14.         if (PlayerTeamManager.CarLobbyColor == "Blue")
    15.         {
    16.             this.GetComponent<MeshRenderer>().material.color =;
    17.         }
    18.     }
    19. }
    One more thing:

    I put this text here, because if i put it on the top, no one would answer the question because they would get hit by the hard truth.

    I dont think that this forum is too small to answer some SIMPLE UNet problems, and I dont think I really ever said something really rude to anyone. So? I dont know whats going on. I dont need assets, I dont need references and Unity Manual links, because Unity Manuals are trash in this situation. Just give me a code snippet or a SIMPLE easiliy understandable explanation! JUST PLEASE HELP! NOTHING ELSE! JUST HELP! Thank you!
    Last edited: Jul 10, 2018