Advertisement
Guest User

Untitled

a guest
Jun 14th, 2014
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.26 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class RandomMatchMakerScript : MonoBehaviour
  5. {
  6.         // Use this for initialization
  7.         void Start ()
  8.         {
  9.                 PhotonNetwork.ConnectUsingSettings ("0.1");
  10.         }
  11.        
  12.         void OnGUI ()
  13.         {
  14.                 GUILayout.Label (PhotonNetwork.connectionStateDetailed.ToString ());
  15.         }
  16.  
  17.         void OnJoinedLobby ()
  18.         {
  19.                 PhotonNetwork.JoinRandomRoom ();
  20.                
  21.         }
  22.  
  23.         void OnPhotonRandomJoinFailed ()
  24.         {
  25.                 Debug.Log ("Can't join random room!");
  26.                 PhotonNetwork.CreateRoom (null);
  27.         }
  28.  
  29.         void OnJoinedRoom ()
  30.         {
  31.                 GameObject player = PhotonNetwork.Instantiate ("PlayerPrefab", Vector3.zero, Quaternion.identity, 0);
  32.                 BotControlScript controller = player.GetComponent<BotControlScript> ();
  33.                 controller.enabled = true;
  34.                 PhotonView pvPlayer = player.GetComponent<PhotonView> ();
  35.  
  36.                 Transform plCam = player.transform.Find ("CamPos");
  37.                 if (pvPlayer.isMine)
  38.                         plCam.gameObject.SetActive (true);
  39.                 else
  40.                         plCam.gameObject.SetActive (false);
  41.  
  42.                
  43.                 if (pvPlayer.isMine) {
  44.                         GameObject camera = PhotonNetwork.Instantiate ("CameraPrefab", Vector3.zero, Quaternion.identity, 0);
  45.                         ThirdPersonCamera tpsCam = camera.GetComponent<ThirdPersonCamera> ();
  46.                         tpsCam.enabled = true;
  47.                 }
  48.         }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement