Advertisement
Munchy2007

Unet5TutPt3NetworkPlayerV2

Feb 16th, 2016
8,471
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.56 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3. using UnityEngine.Networking;
  4.  
  5. public class NetworkPlayer : NetworkBehaviour {
  6.     [SyncVar] public string playerID;
  7.     Camera playerCam;
  8.  
  9.     void Awake()
  10.     {
  11.         playerCam = GetComponentInChildren<Camera>();
  12.         playerCam.gameObject.SetActive(false);
  13.     }
  14.  
  15.     [Command]
  16.     void CmdSetPlayerID(string newID)
  17.     {
  18.         playerID = newID;
  19.     }
  20.  
  21.     public override void OnStartLocalPlayer ()
  22.     {
  23.         string myPlayerID = string.Format("Player {0}", netId.Value);
  24.         CmdSetPlayerID(myPlayerID);
  25.         playerCam.gameObject.SetActive(true);
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement