Search Unity

  1. Check out the Unite LA keynote for updates on the Visual Effect Editor, the FPS Sample, ECS, Unity for Film and more! Watch it now!
    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. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  4. Want more efficiency in your development work? Sign up to receive weekly tech and creative know-how from Unity experts.
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  6. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Transferring Data between Lobby and Game Player Prefab?

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

  1. GVT017


    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