- Home /
Question by
Weirdo-Studios · Jul 07, 2013 at 12:54 PM ·
networkingrandomphotonspawnpoints
Spawning In Photon C#
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);
}
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613105626im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Network: Random spawn 1 Answer
Spawn players in unique places (Photon networking) Object sync problem for entering players. 0 Answers
Photon - Loads a level but doesn't spawn player. 1 Answer
How do I Photon Instantiate a scene object randomly from a list of objects? 0 Answers
RPC with Random Numbers! 2 Answers