So, I am currently using photon for my networking solution but have run into an issue.
I am trying to get my player to spawn on a randomly selected spawnpoint in the game when they enter a room.
This is what i have done so far but I don’t code in C# so therefore need some help with this.
using UnityEngine;
using System.Collections;
public class NetworkManager : Photon.MonoBehaviour {
public GameObject SpawnPoint;
public Object Respawns;
// Use this for initialization
void Start () {
PhotonNetwork.ConnectUsingSettings("Alhpa 0.2");
if (Respawns == null)
GameObject.FindGameObjectsWithTag("Respawn");
}
void OnGUI () {
GUILayout.Label (PhotonNetwork.connectionStateDetailed.ToString());
}
void OnJoinedLobby() {
PhotonNetwork.JoinRandomRoom();
}
void OnPhotonRandomJoinFailed(){
PhotonNetwork.CreateRoom(null);
}
void OnJoinedRoom() {
GameObject Player = PhotonNetwork.Instantiate ("Player", Respawns.transform.position, Respawns.transform.rotation, 0);
}
}