Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //////////////////////////NETWORK SCRIPT////////////////////////////
- using UnityEngine;
- public class Network : Photon.PunBehaviour
- {
- private PhotonView myPhotonView;
- // Use this for initialization
- void Start()
- {
- PhotonNetwork.ConnectUsingSettings("0.1");
- }
- public override void OnJoinedLobby()
- {
- Debug.Log("JoinRandom");
- PhotonNetwork.JoinRandomRoom();
- }
- public override void OnConnectedToMaster()
- {
- PhotonNetwork.JoinRandomRoom();
- }
- public void OnPhotonRandomJoinFailed()
- {
- PhotonNetwork.CreateRoom(null);
- }
- public override void OnJoinedRoom()
- {
- GameObject player = PhotonNetwork.Instantiate("Player", Vector3.zero, Quaternion.identity, 0);
- myPhotonView = player.GetComponent<PhotonView>();
- }
- }
- //////////////////////////PLAYER SCRIPT////////////////////////////
- using UnityEngine;
- public class Player : Photon.MonoBehaviour
- {
- private Vector3 targetPos;
- // Use this for initialization
- void Start ()
- {
- if (!photonView.isMine)
- this.enabled = false;
- targetPos = transform.position;
- }
- // Update is called once per frame
- void Update ()
- {
- if(Input.GetMouseButtonDown(0))
- {
- targetPos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
- targetPos.z = 0;
- }
- transform.position = Vector3.MoveTowards(transform.position, targetPos, 3.5F * Time.deltaTime);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement