Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class RandomMatchMakerScript : MonoBehaviour
- {
- // Use this for initialization
- void Start ()
- {
- PhotonNetwork.ConnectUsingSettings ("0.1");
- }
- void OnGUI ()
- {
- GUILayout.Label (PhotonNetwork.connectionStateDetailed.ToString ());
- }
- void OnJoinedLobby ()
- {
- PhotonNetwork.JoinRandomRoom ();
- }
- void OnPhotonRandomJoinFailed ()
- {
- Debug.Log ("Can't join random room!");
- PhotonNetwork.CreateRoom (null);
- }
- void OnJoinedRoom ()
- {
- GameObject player = PhotonNetwork.Instantiate ("PlayerPrefab", Vector3.zero, Quaternion.identity, 0);
- BotControlScript controller = player.GetComponent<BotControlScript> ();
- controller.enabled = true;
- PhotonView pvPlayer = player.GetComponent<PhotonView> ();
- Transform plCam = player.transform.Find ("CamPos");
- if (pvPlayer.isMine)
- plCam.gameObject.SetActive (true);
- else
- plCam.gameObject.SetActive (false);
- if (pvPlayer.isMine) {
- GameObject camera = PhotonNetwork.Instantiate ("CameraPrefab", Vector3.zero, Quaternion.identity, 0);
- ThirdPersonCamera tpsCam = camera.GetComponent<ThirdPersonCamera> ();
- tpsCam.enabled = true;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement