Quantcast
Channel: Multiplayer
Viewing all articles
Browse latest Browse all 16796

Syncing Usernames (Textmeshes) over the network?

$
0
0
Code (CSharp):
  1. using UnityEngine;
  2. using System.Collections;
  3. using UnityEngine.Networking;
  4.  
  5. public class PlayerName : NetworkBehaviour
  6. {
  7.     [SyncVar]
  8.     public string playerCurrentName;
  9.     public TextMesh playerNameMesh;
  10.  
  11.     void Update()
  12.     {
  13.         if (!isServer)
  14.             return;
  15.  
  16.         playerNameMesh.text = playerCurrentName;
  17.  
  18.         GetComponent<Transform>().name = playerCurrentName;
  19.     }
  20. }
  21.  
Nothing really shows up on the client side, but the host sees everything

Viewing all articles
Browse latest Browse all 16796

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>